Proper divisors: Difference between revisions

m
Added Sidef
m (Added Sidef)
Line 2,111:
(1L +: products).filter(_ < n)
}</lang>
 
=={{header|Sidef}}==
{{trans|Perl 6}}
<lang ruby>func propdiv (x) {
var divs = []
divs << 1 if (x > 1)
 
for d in (2 ..^ x.isqrt) {
var y = (x // d)
if (y*d == x) {
divs << d
y == d || (divs << y)
}
}
 
divs
}
 
10.times { |i| say "#{i}\t#{propdiv(i).dump}" }
 
var max = 0
var candidates = []
for i in (1 ..^ 20_000) {
var divs = propdiv(i).len
if (divs > max) {
candidates = []
max = divs
}
candidates << i if (divs == max)
}
 
say "max = #{max}, candidates = #{candidates.dump}"</lang>
{{out}}
<pre>
1 []
2 [1]
3 [1]
4 [1, 2]
5 [1]
6 [1, 2, 3]
7 [1]
8 [1, 2, 4]
9 [1, 3]
10 [1, 2, 5]
max = 79, candidates = [15120, 18480]
</pre>
 
=={{header|Swift}}==
2,747

edits