Proper divisors: Difference between revisions

Content deleted Content added
m →‎version 3: added whitespace, changed some comments.
Thundergnat (talk | contribs)
m →‎{{header|Perl 6}}: Further optimization
Line 2,838: Line 2,838:
=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{Works with|rakudo|2018.10}}
{{Works with|rakudo|2018.10}}
Once your threshold is over 1000, the maximum proper divisors will always include 2 and 5 as divisors, so only bother to check multiples of 2 and 5.
Once your threshold is over 1000, the maximum proper divisors will always include 2, 3 and 5 as divisors, so only bother to check multiples of 2, 3 and 5.


There really isn't any point in using concurrency for a limit of 20_000. The setup and bookkeeping drowns out any benefit. Really doesn't start to pay off until the limit is 50_000 and higher. Try swapping in the commented out race map iterator line below for comparison.
There really isn't any point in using concurrency for a limit of 20_000. The setup and bookkeeping drowns out any benefit. Really doesn't start to pay off until the limit is 50_000 and higher. Try swapping in the commented out race map iterator line below for comparison.
Line 2,852: Line 2,852:


my @candidates;
my @candidates;
loop (my int $c = 10; $c <= 20_000; $c += 10) {
loop (my int $c = 30; $c <= 20_000; $c += 30) {
#(10, *+10 ... 200_000).race.map: -> $c {
#(30, *+30 …^ * > 500_000).race.map: -> $c {
my \mx = +propdiv($c);
my \mx = +propdiv($c);
next if mx < @candidates - 1;
next if mx < @candidates - 1;