View Code of Problem 3696

#include<bits/stdc++.h> 
using namespace std;

int main(){
	int n;
	while(cin>>n){
		if(n==0)
			cout<<1<<endl;
		else{
			int gewei=n%10;
			for(int i=0;i<n-1;i++){
				int temp=gewei*n;
				gewei=temp%10;
		}
			cout<<gewei<<endl;	
		}
		
	}
	
}

Double click to view unformatted code.


Back to problem 3696