RosettaCodeData/Task/Count-in-factors/FutureBasic/count-in-factors.basic

26 lines
464 B
Plaintext

local fn Factorial( num as long ) as CFStringRef
CFStringRef x, f, result
long fct
f = @"" : x = @""
if num = 1 then result = @" 1" : exit fn
fct = 2
while ( fct <= num )
if ( num mod fct == 0 )
f = fn StringWithFormat( @"%@%@%@", f, x, str( fct ) )
x = @" x"
num = num / fct
else
fct++
end if
wend
result = f
end fn = result
long i
for i = 1 to 20
printf @"%2ld =%@", i, fn Factorial(i)
next
HandleEvents