HDU 1163 Eddy's digital Roots
#include<stdio.h>

int ncase,n,p;

int main()
{
	while (scanf("%d",&n),n) {
		p=1;
		for (int i=0; i<n; i++) {
			p*=n;
			p%=9;
		}
		if(p) printf("%d\n",p);
		else printf("9\n");
	}
}
posted on 2011-07-05 17:22  Eucalyptus  阅读(111)  评论(0编辑  收藏  举报