RosettaCodeData/Task/Prime-decomposition/AutoHotkey/prime-decomposition.ahk
2014-01-17 05:34:36 +00:00

17 lines
254 B
AutoHotkey

MsgBox % factor(8388607) ; 47 * 178481
factor(n)
{
if (n = 1)
return
f = 2
while (f <= n)
{
if (Mod(n, f) = 0)
{
next := factor(n / f)
return, % f "`n" next
}
f++
}
}