-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlarge_factorials.c
50 lines (42 loc) · 892 Bytes
/
large_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
int main()
{
int a[16500], T;
long long int i, j;
printf("Enter number of test cases : ");
scanf("%d", &T);
while (T--)
{
for (i = 0; i < 16500; i++)
{
a[i] = 0;
}
a[1] = 1;
int N, carry = 0, count = 0;
printf("Enter a number : ");
scanf("%d", &N);
for (i = 1; i <= N; i++)
{
carry = 0;
for (j = 0; j < 16500; j++)
{
a[j] = a[j] * i + carry;
carry = a[j] / 10;
a[j] = a[j] % 10;
}
}
for (i = 0; i < 16500; i++)
{
if (a[i] != 0)
{
count = i;
}
}
for (i = count; i > 0; i--)
{
printf("%d", a[i]);
}
printf("\n");
}
return 0;
}