Count in factors: Difference between revisions

→‎{{header|AutoHotkey}}: AutoHotkey example added
(→‎{{header|AutoHotkey}}: AutoHotkey example added)
Line 87:
15: 3 x 5</pre>
 
=={{header|AutoHotkey}}==
{{trans|D}}
<lang AutoHotkey>factorize(n){
if n = 1
return 1
if n < 1
return false
result := 0, m := n, k := 2
While n >= k{
while !Mod(m, k){
result .= " * " . k, m /= k
}
k++
}
return SubStr(result, 5)
}
Loop 22
out .= A_Index ": " factorize(A_index) "`n"
MsgBox % out</lang>
Output:
<pre>1: 1
2: 2
3: 3
4: 2 * 2
5: 5
6: 2 * 3
7: 7
8: 2 * 2 * 2
9: 3 * 3
10: 2 * 5
11: 11
12: 2 * 2 * 3
13: 13
14: 2 * 7
15: 3 * 5
16: 2 * 2 * 2 * 2
17: 17
18: 2 * 3 * 3
19: 19
20: 2 * 2 * 5
21: 3 * 7
22: 2 * 11</pre>
=={{header|C}}==
Code includes a dynamically extending prime number list. The program doesn't stop until you kill it, or it runs out of memory, or it overflows.