CalmoSoft primes: Difference between revisions
m
→{{header|Raku}}: Doh! Accidentally left off last prime in sliding window. Fixed
(Algol 68 stretch - corrected comment) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: Doh! Accidentally left off last prime in sliding window. Fixed) |
||
Line 485:
=={{header|Raku}}==
Longest sliding window prime sums
<syntaxhighlight lang="raku" line>use Lingua::EN::Numbers;
sub sliding-window(@list, $window) { (^(+@list - $window)).map: { @list[$_ ..
for flat (1e2, 1e3, 1e4, 1e5).map: { (1, 2.5, 5) »×» $_ } -> $upto {
Line 499 ⟶ 498:
my @sums = @primes.&sliding-window($_).grep: { .sum.is-prime }
next unless @sums;
say "\nFor primes up to {$upto.Int.&cardinal}:\nLongest sequence of consecutive primes yielding a prime sum: elements: {comma 1+$_}";
for @sums { say " {join '...', .[0..5, *-5..*]».&comma».join(' + ')}, sum: {.sum.&comma}" }
last
Line 510 ⟶ 509:
For primes up to two hundred fifty:
Longest sequence of consecutive primes yielding a prime sum: elements:
For primes up to five hundred:
Longest sequence of consecutive primes yielding a prime sum: elements:
For primes up to one thousand:
Longest sequence of consecutive primes yielding a prime sum: elements:
For primes up to two thousand, five hundred:
Line 538 ⟶ 534:
For primes up to twenty-five thousand:
Longest sequence of consecutive primes yielding a prime sum: elements: 2,
For primes up to fifty thousand:
Longest sequence of consecutive primes yielding a prime sum: elements: 5,
For primes up to one hundred thousand:
Line 550 ⟶ 546:
For primes up to two hundred fifty thousand:
Longest sequence of consecutive primes yielding a prime sum: elements: 22,
For primes up to five hundred thousand:
|