大数阶乘(高精度)

时间:2021-11-06 13:53:20
#include <iostream>
using namespace std;


int main()
{
	int n, m, temp;
	//余数remainder 进位carry_bit 
	int remainder=0, carry_bit=0;
	cin>>m;
	int a[10000];
	for(int i=0; i<10000; i++) a[i]=0;
	a[1] = 1;
	for(int n=2; n<=m; n++)
	{
		remainder=0, carry_bit=0;
		for(int i=1; i<10000; i++)
		{
			temp = a[i]*n+carry_bit;
			remainder = temp%10;
			carry_bit = temp/10;
			a[i] = remainder;
		}
	}
	int i=9999;
	while(a[i]==0) i--;i++;
	while(--i!=0) printf("%d", a[i]);
	return 0;
}