-
-
Save fullmated/5e6a9841a6c8b1823230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define N 81 | |
/* N: 長桁計算に用意する桁数 */ | |
int main(int argc, char *argv[]){ | |
char a[N],b[N],p[N]; | |
int x,i,m; | |
m=1; | |
scanf("%d",&x); | |
for(i=0; i!=N; i=i+1){a[i]=p[i]=0;} | |
a[0]=1; | |
while(1){ | |
for(i=0; i!=N; i=i+1){b[i]=a[i];} | |
a[0]=m*a[0]; | |
p[0]=a[0]/10; | |
a[0]=a[0]-10*p[0]; | |
for(i=0; i!=N; i=i+1){ | |
a[i+1]=m*a[i+1]+p[i]; | |
p[i+1]=a[i+1]/10; | |
a[i+1]=a[i+1]-10*p[i+1]; | |
} | |
for(i=0; i!=N; i=i+1){p[i]=0;} | |
m=m+1; | |
if(a[x]!=0){break;} | |
} | |
for(i=N; i!=1 && b[i-1]==0; i= i-1) printf(""); | |
/* 残りの桁を数字列として書き出す */ | |
while( i!=0 ){ printf("%1d", b[i-1]); i= i-1;} | |
/*改行*/ | |
printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment