View Code of Problem 3696

#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0){
			cout<<0<<endl;
		}else{
			int last=n%10;
			for(int i=1;i<n;i++){
				last=last*n%10;
			}
			cout<<last<<endl;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3696