Ormiston pairs: Difference between revisions

Content added Content deleted
(→‎{{header|Wren}}: No longer requires pairs to be disjoint. Extended search to 1 billion.)
(→‎{{header|Go}}: Updated in line with latest Wren version.)
Line 274: Line 274:


func main() {
func main() {
const limit = 1e7
const limit = 1e9
primes := rcu.Primes(limit)
primes := rcu.Primes(limit)
var orm30 [][2]int
var orm30 [][2]int
i := 0
j := int(1e5)
j := int(1e5)
count := 0
count := 0
var counts []int
var counts []int
for i < len(primes)-1 {
for i := 0; i < len(primes)-1; i++ {
p1 := primes[i]
p1 := primes[i]
p2 := primes[i+1]
p2 := primes[i+1]
if (p2-p1)%18 != 0 {
if (p2-p1)%18 != 0 {
i++
continue
continue
}
}
Line 301: Line 299:
}
}
count++
count++
i += 2
} else {
i++
}
}
}
}
Line 314: Line 309:
}
}
}
}
fmt.Println()
fmt.Printf("\n%d Ormiston pairs before 100,000\n", counts[0])
j = int(1e5)
fmt.Printf("%d Ormiston pairs before 1,000,000\n", counts[1])
for i := 0; i < len(counts); i++ {
fmt.Printf("%s Ormiston pairs before 10,000,000\n", rcu.Commatize(counts[2]))
fmt.Printf("%s Ormiston pairs before %s\n", rcu.Commatize(counts[i]), rcu.Commatize(j))
j *= 10
}
}</syntaxhighlight>
}</syntaxhighlight>


Line 336: Line 334:
382 Ormiston pairs before 1,000,000
382 Ormiston pairs before 1,000,000
3,722 Ormiston pairs before 10,000,000
3,722 Ormiston pairs before 10,000,000
34,901 Ormiston pairs before 100,000,000
326,926 Ormiston pairs before 1,000,000,000
</pre>
</pre>