View Code of Problem 3696

#include <stdio.h>
#include <string.h>
#include <math.h>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		if (n == 0) {
			printf("1\n");
		}
		else {
			int x = n-1;
			int a=n%10;
			while (x--) {
				a = (n * a) % 10;
			}
			printf("%d\n", a);
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3696