Proper divisors: Difference between revisions
Content added Content deleted
Alpha bravo (talk | contribs) (Added AutoHotkey) |
Alpha bravo (talk | contribs) |
||
Line 900: | Line 900: | ||
<lang AutoHotkey>proper_divisors(n) { |
<lang AutoHotkey>proper_divisors(n) { |
||
Array := [] |
Array := [] |
||
⚫ | |||
if n = 1 |
if n = 1 |
||
return Array |
return Array |
||
⚫ | |||
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>--------------------------- |
|||
⚫ | |||
Temp.ahk |
|||
⚫ | |||
--------------------------- |
|||
⚫ | |||
⚫ | |||
3 1 3 2 |
|||
1 0 |
|||
⚫ | |||
⚫ | |||
4 1 2 2 |
4 1 2 2 |
||
5 1 1 |
5 1 1 |