'' Factorial 2012-04-20 WhTurner (RDT140-0)
''========================================================================
'' Adjustable parameters:
First= 190 '' first factorial in output (make equal to Last for only one factorial)
Last= 200 '' last factorial in output
Sdigit= 10 '' number of significant digits in scientific notation (1..12) - use 0(zero) for string output
Ts= " " ''Thousands separator ( " " space ; "," comma or "" nothing )
Ds= "." ''Decimal separator
''========================================================================
'' Var Init:
m[1]= 1
Mmax= 1
Empty= " "
''========================================================================
For i= 1 To Last
Multiply()
If i >= First Then ''output
Tout= m[Mmax]
For j= Mmax-1 To 1 Step -1
out= "x00000000"+m[j]
Lout= Text.GetLength(out)
out= Text.GetSubTextToEnd(out,Lout-5)
Tout= Text.Append(Tout,out)
EndFor
EndIf ''output
EndFor
''========================================================================
Sub Multiply
''in/output vars: m[1..Mmax] array for 6-digit parts
'' Mmax: maximum index of array; mult: multiplier
''local vars: M_i M_carry
For M_i= 1 To Mmax
m[M_i]= m[M_i]*i
EndFor
For M_i= 1 To Mmax
M_carry= Math.Floor(m[M_i]/1000000)
m[M_i]= Math.Remainder(m[M_i],1000000)
m[1+M_i]= M_carry+m[1+M_i]
EndFor