> I have some thoughts on solving this Quora Challenge which I will post in
a bit.
First, a teaser, computed completely in Dyalog APL with no additional C
coding.
t←(1e6+2e9) pc 2e6+2e9
⍴t
185
5↑t
2001401814 2001401815 2001401816 2001401817 2001401818
¯5↑t
2001401994 2001401995 2001401996 2001401997 2001401998
t ≡ (1↑t)+⍳185
1
+/ 1 pco t
0
⍝ that is, all composite
1 pco ( 1↑t)-1
1
1 pco (¯1↑t)+1
1
⍝ that is, the interval is bracketed by primes
1 1 cmpx '(1e6+2e9) pc 2e6+2e9'
0.074125
Takes 0.074 seconds on my machine.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm