The sum of factorial
"Title description" calculates the s=1! with high precision +2! +3! +...+n! (N≤50)
Which "! "denotes factorial, for example: 5! =5*4*3*2*1.
"Input format" a positive integer n.
"Output format" a positive integer s that represents the result of the calculation.
Train of thought: stripping by heightening the essence Plus
ProgramAA;varN,l,ls,i:longint; A:Array[1.. +] ofLongint; S:Array[1.. +] ofThe longint;//s array is the next number to be added, which is the change. procedureJC (I:longint);//This process is used to find the S arrayvarJ:longint;begin ifI=1 Then beginL:=1; LS:=1; S[LS]:=1; Exit End; ifI>1 Then begin forj:=1 toLs Dos[j]:=s[j]*i;//think about doing this for Mao. forj:=1 toLs Do ifs[j]>=Ten Then beginInc (S[j+1],S[J]Div Ten); S[J]:=S[J]MoD Ten; End; ifs[ls+1]<>0 ThenInc (LS); while s[ls]>=10 Do beginInc (LS); Inc (S[ls],s[ls-1]Div Ten); S[ls-1]:=s[ls-1]MoD Ten; End; ifLs>=l Thenl:=ls; End;End;procedureWork ;varI,j,k:longint;begin fori:=1 toNThe number of do//currently to be added is the factorial of I. beginJC (i); forj:=1 toL DoInc (A[J],S[J]);//A few steps to add factorial to a forj:=1 toL Do ifa[j]>=Ten Then beginInc (A[j+1],A[J]Div Ten); A[J]:=A[J]MoD Ten; End; ifa[l+1]<>0 ThenInc (L); whilea[l]>=Ten Do beginInc (L); Inc (A[l],a[l-1]Div Ten); A[l-1]:=a[l-1]MoD Ten; End; End;End;beginREADLN (n); Work forI:=lDownto 1 Dowrite (a[i]);End.
A little reflection: At the beginning of the 215, because the red Word part of the error, written a array of ...
The sum of factorial