-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmall factorials.c
32 lines (32 loc) · 955 Bytes
/
Small factorials.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<stdio.h>
int main()
{
int t,a[160],n,i,j,temp,m,x;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
a[0]=1;
m=1;
temp = 0;
for(i=1;i<=n;i++)
{
for(j=0;j<m;j++)
{
x = a[j]*i+temp;
a[j]=x%10;
temp = x/10;
}
while(temp!=0)
{
a[m]=temp%10;
temp = temp/10;
m++;
}
}
for(i=m-1;i>=0;i--)
printf("%d",a[i]);
printf("\n");
}
return 0;
}