#include<stdio.h> unsigned long int a[21]; void init(){ a[0]=a[1]=1; } int main(int argc, char *argv[]) { int n; init(); while(~scanf("%d",&n)) { if(a[n]) printf("%lu ",a[n]); else { int i=2; while(a[i])i++; for(;i<=n;++i) { a[i]=a[i-1]*i; } printf("%lu ",a[n]); } } return 0; } /************************************************************** Problem: 1067 User: kirchhoff Language: C Result: Accepted Time:0 ms Memory:912 kb ****************************************************************/