Proper divisors: Difference between revisions
→{{header|langur}}
(add RPL) |
Langurmonkey (talk | contribs) |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 2,242:
10: [1, 2, 5]
15120: 79</pre>
=={{header|EasyLang}}==
<syntaxhighlight>
proc propdivs n . divs[] .
divs[] = [ ]
if n < 2
return
.
divs[] &= 1
sqr = sqrt n
for d = 2 to sqr
if n mod d = 0
divs[] &= d
if d <> sqr
divs[] &= n / d
.
.
.
.
for i to 10
propdivs i d[]
write i & ":"
print d[]
.
for i to 20000
propdivs i d[]
if len d[] > max
max = len d[]
maxi = i
.
.
print maxi & " has " & max & " proper divisors."
</syntaxhighlight>
=={{header|EchoLisp}}==
Line 2,762 ⟶ 2,795:
</pre>
=={{header|Frink}}==
Line 3,736 ⟶ 3,694:
=={{header|langur}}==
{{trans|Go}}
<syntaxhighlight lang="langur">val .getproper = fn(.x) { for[=[]] .i of .x \ 2 { if .x div .i: _for ~= [.i] } }
val .listproper =
if .x < 1: return null
for[=""] .i of .x {
}
}
writeln "The proper divisors of the following numbers are :"
writeln .listproper(10)
var .max = 0
Line 5,893 ⟶ 5,849:
=={{header|RPL}}==
{{works with|HP|49}}
≪ DIVIS REVLIST TAIL REVLIST <span style="color:grey">@ or DIVIS 1 OVER SIZE 1 - SUB</span>
≫ '<span style="color:blue">PDIVIS</span>' STO
Line 5,903 ⟶ 5,859:
DROP
'''NEXT'''
DROP n DUP <span style="color:blue">PDIVIS</span> SIZE
≫ ≫ '<span style="color:blue">TASK2</span>' STO
Line 6,231 ⟶ 6,187:
{{trans|Raku}}
<syntaxhighlight lang="ruby">func propdiv (n) {
n.divisors.
}
Line 6,573 ⟶ 6,529:
{{libheader|Wren-fmt}}
{{libheader|Wren-math}}
<syntaxhighlight lang="
import "./math" for Int
for (i in 1..10) System.print("%(Fmt.d(2, i)) -> %(Int.properDivisors(i))")
|