18 lines
486 B
Plaintext
18 lines
486 B
Plaintext
var limit = 1e6
|
|
var primes = limit.primes
|
|
|
|
say "Groups of successive primes <= #{limit.commify}:"
|
|
|
|
for diffs in [[2], [1], [2,2], [2,4], [4,2], [6,4,2]] {
|
|
|
|
var groups = []
|
|
primes.each_cons(diffs.len+1, {|*group|
|
|
if (group.map_cons(2, {|a,b| b-a}) == diffs) {
|
|
groups << group
|
|
}
|
|
})
|
|
|
|
say ("...for differences #{diffs}, there are #{groups.len} groups, where ",
|
|
"the first group = #{groups.first} and the last group = #{groups.last}")
|
|
}
|