#include<stdio.h> int main() { int n; while(scanf("%d",&n)==1) { if(n==0) break; long num1[300000],lnum1=1,i,j,k,m,r=0,sum=0; num1[0]=1; for(i=2;i<=n;i++) { for(j=0;j<lnum1;j++) { m=(num1[j]*i+r)%10; r=(num1[j]*i+r)/10; num1[j]=m; } while(r!=0) { num1[lnum1++]=r%10; r=r/10; } } for(i=0;i<lnum1;i++) { if(num1[i]>0) break; } printf("%5d -> %d\n",n,num1[i]); } return 0; }
No comments:
Post a Comment