Photolog

Through the Looking-Glass
2010-10-12: Through the Looking-Glass
My radio speaks is binary!
2010-10-10: My radio speaks is binary!
Gigaminx: (present for my birthday)
2010-09-16: Gigaminx: (present for my birthday)
Trini on bike
2010-09-05: Trini on bike
Valporquero
2010-08-28: Valporquero
My new bike!
2010-08-22: My new bike!
Mario and Ana's wedding
2010-08-13: Mario and Ana's wedding
Canyoning in Guara
2010-08-07: Canyoning in Guara
Trini and Mari in Marbella
2010-08-05: Trini and Mari in Marbella
Trini and Chelo in Tabarca
2010-08-03: Trini and Chelo in Tabarca
Valid XHTML 1.1
Log in
Back to list of problems

Just the Facts

568.c

/* Just the Facts */
#include <stdio.h>

int
facts(int n) {
	int i;
	int s=1;

	for(i=2; i<=n; i++) {
		s *= i;
		while((s%10)==0) {
			s /= 10;
		}
		s %= 100000;
	}
	return s % 10;
}

int
main(void) {
	int n;

	while(scanf("%d", &n)==1) {
		printf("%5d -> %d\n", n, facts(n));
	}
	exit(0);
}