//利用数组计算阶乘
#include <iostream>
using namespace std;
int main()
{
	const int MAXSIZE=200;
	int array[MAXSIZE];
	int n;
	cout<<"n=";
	cin>>n;

	
	//计算n！的位数len
	double mul=1;
	int len=1,i;
	for(i=1;i<=n;i++)
	{
		mul=mul*i;
		while(mul>=10.0) 
		{
			len++;
			mul/=10;
		}
	}
	cout<<"n!共有位数："<<len<<endl;

	
	int sum,sc;
	int j;
	for(i=0;i<len;i++)
		array[i]=0;
	array[0]=1;
	for(i=2;i<=n;i++)
	{
		sc=0;
		for(j=0;j<len;j++)
		{
			sum=array[j]*i+sc;
			array[j]=sum%10;
			sc=sum/10;
		}
	}
	cout<<n<<"!=";

	for(i=len-1;i>=0;i--)
		cout<<array[i];
	cout<<endl;
	return 0;
}
