Cousin primes: Difference between revisions

Content added Content deleted
m (Added a general comment.)
(Change syntax for "collect" to work with Nim 1.4.8. Previous syntax worked only in development version.)
Line 975: Line 975:


const
const
PrimeList = collect:
PrimeList = collect(newSeq):
for n in 2..N:
for n in 2..N:
if n.isPrime: n
if n.isPrime: n
PrimeSet = PrimeList.toHashSet
PrimeSet = PrimeList.toHashSet


let cousinList = collect:
let cousinList = collect(newSeq):
for n in PrimeList:
for n in PrimeList:
if (n + 4) in PrimeSet: (n, n + 4)
if (n + 4) in PrimeSet: (n, n + 4)