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");
		else if(n%4==1){
			printf("%lld\n",n%10);
		}
		else if(n%4==2){
			n=n%10;
			printf("%lld\n",n*n%10);
		}
		else if(n%4==3){
			n=n%10;
			printf("%lld\n",n*n*n%10);
		}
		else
		printf("%lld\n",n*n*n*n%10);
	}
}

Double click to view unformatted code.


Back to problem 3696