#include<stdio.h>
#include<malloc.h>
#define MAXN 1000
void pnext(int a[], int k)
{
int *b, m = a[0];
int i, j, r, carry;
b = (int *)malloc(sizeof(int) * (m + 1));
for (i = 1; i <= m; i++)
{
b[i] = a[i];
}
for (j = 1; j < k; j++)
{
for (carry = 0, i = 1; i <= m; i++)
{
r = (i <= a[0] ? (a[i] + b[i]) : a[i]) + carry;
a[i] = r % 10;
carry = r / 10;
}
if (carry != 0)
{
a[++m] = carry;
}
}
free(b);
a[0] = m;
}
void write(int *a, int k)
{
printf("%4d! =", k);
for (int i = a[0]; i > 0; i--)
{
printf("%d", a[i]);
}
printf("
");
}
void main()
{
int Num[MAXN], n;
printf("Enter the number n:");
scanf("%d", &n);
Num[0] = 1;
Num[1] = 1;
write(Num, 1);
for (int i = 2; i <= n; i++)
{
pnext(Num, i);
write(Num, i);
}
}