Proper divisors: Difference between revisions

Content added Content deleted
(Added AutoHotkey)
Line 900: Line 900:
<lang AutoHotkey>proper_divisors(n) {
<lang AutoHotkey>proper_divisors(n) {
Array := []
Array := []
Array[1] := true
if n = 1
if n = 1
return Array
return Array
Array[1] := true
x := Floor(Sqrt(n))
x := Floor(Sqrt(n))
loop, % x+1
loop, % x+1
if !Mod(n, i:=A_Index+1)
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor(n/i)] := true
Array[floor(n/i)] := true
Loop % n/x
Loop % n/x
if !Mod(n, i:=A_Index+1)
if !Mod(n, i:=A_Index+1) && (i < n)
Array[i] := true
Array[i] := true
return Array
return Array
Line 931: Line 931:
return</lang>
return</lang>
{{out}}
{{out}}
<pre>---------------------------
<pre>Number Divisors Count
Temp.ahk
1 1 1
---------------------------
2 1 2 2
Number Divisors Count
3 1 3 2
1 0
2 1 1
3 1 1
4 1 2 2
4 1 2 2
5 1 1
5 1 1