Factors of an integer: Difference between revisions
m
→{{header|Sidef}}: updated code and output
m (→{{header|Sidef}}: updated code and output) |
|||
Line 3,772:
=={{header|Sidef}}==
<lang ruby>func factors(n) {
gather {
} << 1..n.isqrt
}.sort.uniq
}
for n [53, 64, 32766]
say "factors(#{n}): #{factors(n)}"
}</lang>
{{out}}
<pre>
factors(53): [1, 53]
factors(64): [1, 2, 4, 8, 16, 32, 64]
factors(32766): [1, 2, 3, 6, 43, 86, 127, 129, 254, 258, 381, 762, 5461, 10922, 16383, 32766]
</pre>
|