Jump to content

Abundant odd numbers: Difference between revisions

No edit summary
Line 3,427:
First abundant odd number above 10^9, with divisor sum:
(1000000575,1083561009)</pre>
 
=={{header|jq}}==
<lang jq>
# The factors, unsorted
def factors:
. as $num
| reduce range(1; 1 + sqrt|floor) as $i
([];
if ($num % $i) == 0 then
($num / $i) as $r
| if $i == $r then . + [$i] else . + [$i, $r] end
else .
end) ;
 
def abundant_odd_numbers:
range(1; infinite; 2)
| (factors | add) as $sum
| select($sum > 2*.)
| [., $sum] ;</lang>
 
Computing the 10^9 abundant number is presently impractical using jq, but for the other tasks:
<lang>( ["n", "sum of divisors"],
limit(25; abundant_odd_numbers)),
[],
(["The 1000th abundant odd number and corresponding sum of divisors:"]
+ nth(999; abundant_odd_numbers))
| @tsv
</lang>
{{out}}
<pre>
n sum of divisors
945 1920
1575 3224
2205 4446
2835 5808
3465 7488
4095 8736
4725 9920
5355 11232
5775 11904
5985 12480
6435 13104
6615 13680
6825 13888
7245 14976
7425 14880
7875 16224
8085 16416
8415 16848
8505 17472
8925 17856
9135 18720
9555 19152
9765 19968
10395 23040
11025 22971
 
The 1000th abundant odd number and corresponding sum of divisors: 492975 1012336
</pre>
 
 
=={{header|Julia}}==
2,478

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.