View Code of Problem 3696

#include<iostream>
#include<cstring>
//#include<algorithm>
using namespace std;
int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n == 0)cout<<1<<endl;
		else{
			int t = 1;
			for(int i = 0;i<n;i++){
				t = t * n;
				t = t % 10;
			}
			cout<<t<<endl;	
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3696