RosettaCodeData/Task/Prime-decomposition/AutoHotkey/prime-decomposition-1.ahk
2023-07-01 13:44:08 -04: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++
}
}