View Code of Problem 3696

#include<stdio.h>
int main(){
	long long int n;
	while(scanf("%lld",&n) != EOF){
		if(n == 0) printf("1\n");
		if(n%4 == 1) printf("%lld\n",n%10);
		else if(n%4 == 2) printf("%lld\n",n*n%10);
		else if(n%4 == 3) printf("%lld\n",n*n*n%10);
		else  printf("%lld\n",n*n*n*n%10);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3696