Consecutive primes with ascending or descending differences: Difference between revisions
Consecutive primes with ascending or descending differences (view source)
Revision as of 09:49, 23 October 2021
, 2 years ago→{{header|Ruby}}: typo
(→{{header|Ruby}}: Add Ruby) |
m (→{{header|Ruby}}: typo) |
||
Line 950:
limit = 1_000_000
puts "First
p Prime.each(limit).each_cons(2).chunk_while{|(i1,i2), (j1,j2)| j1-i1 < j2-i2 }.max_by(&:size).flatten.uniq
puts "\nFirst
p Prime.each(limit).each_cons(2).chunk_while{|(i1,i2), (j1,j2)| j1-i1 > j2-i2 }.max_by(&:size).flatten.uniq</lang>
{{out}}
<pre>First
[128981, 128983, 128987, 128993, 129001, 129011, 129023, 129037]
First
[322171, 322193, 322213, 322229, 322237, 322243, 322247, 322249]
</pre>
|