21 lines
390 B
Text
21 lines
390 B
Text
for i = 1 to 20
|
|
print i, " = ", factorial$(i)
|
|
next i
|
|
end
|
|
|
|
sub factorial$ (num)
|
|
local f$, x$
|
|
f$ = "" : x$ = ""
|
|
if num = 1 return "1"
|
|
fct = 2
|
|
while fct <= num
|
|
if mod(num, fct) = 0 then
|
|
f$ = f$ + x$ + str$(fct)
|
|
x$ = " x "
|
|
num = num / fct
|
|
else
|
|
fct = fct + 1
|
|
end if
|
|
wend
|
|
return f$
|
|
end sub
|