RosettaCodeData/Task/Factorial/M2000-Interpreter/factorial-1.m2000

23 lines
860 B
Plaintext

Module CheckIt {
Locale 1033 ' ensure #,### print with comma
Function factorial (n){
If n<0 then Error "Factorial Error!"
If n>27 then Error "Overflow"
m=1@:While n>1 {m*=n:n--}:=m
}
Const Proportional=4
Const ProportionalLeftJustification=5
Const NonProportional=0
Const NonProportionalLeftJustification=1
For i=1 to 27
\\ we can print over (erasing line first), without new line at the end
\\ and we can change how numbers apears, and the with of columns
\\ numbers by default have right justification
\\ all $() format have temporary use in this kind of print.
Print Over $(Proportional),$("\f\a\c\t\o\r\i\a\l\(#\)\=",15), i, $(ProportionalLeftJustification), $("#,###",40), factorial(i)
Print \\ new line
Next i
}
Checkit