20 lines
398 B
Text
20 lines
398 B
Text
factorize = function( n )
|
|
if n == 1 then return [1] end if
|
|
|
|
k = 2
|
|
res = []
|
|
while n > 1
|
|
while n % k == 0
|
|
res.push( k )
|
|
n /= k
|
|
end while
|
|
k += 1
|
|
end while
|
|
return res
|
|
end function
|
|
|
|
for i in range( 1, 22 )
|
|
iStr = str( i )
|
|
if i < 10 then iStr = " " + iStr end if
|
|
print iStr + ": " + factorize( i ).join( " * " )
|
|
end for
|