Proper divisors: Difference between revisions
m
→{{header|AutoHotkey}}
Alpha bravo (talk | contribs) (Added AutoHotkey) |
Alpha bravo (talk | contribs) |
||
Line 900:
<lang AutoHotkey>proper_divisors(n) {
Array := []
Array[1] := true▼
if n = 1
return Array
▲ Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor(n/i)] := true
Loop % n/x
if !Mod(n, i:=A_Index+1) && (i < n)
Array[i] := true
return Array
Line 931:
return</lang>
{{out}}
<pre>---------------------------
<pre>Number Divisors Count▼
Temp.ahk
1 1 1▼
---------------------------
2 1 2 2▼
1 0
4 1 2 2
5 1 1
|