Since the problem calls for computing the first n primes rather than the i-th prime, sieve probably works best. See http://code.jsoftware.com/wiki/Doc/Articles/Play104 for some ideas.
Using the prime number theorem, (%^.)2.2e9 1.0227e8 The 1e8-th prime is somewhere around 2.2e9 in value. Manageable without resort to extended precision numbers. On Sun, Mar 20, 2016 at 4:44 PM, Raul Miller <[email protected]> wrote: > Rosettacode has a task now, for this item. > > http://rosettacode.org/wiki/Prime_conspiracy#J > > And, hypothetically speaking, it should be straightforward to do the extra > credit problem. But that doesn't work. Given: > > dgpairs=: 2 (,'->',])&":/\ 10 | p: > combine=: ~.@[ ,.~ ' ',.~ ":@,.@(+//.) > > We can try this: > > /:~ combine&;/|: (~.;#/.~)@dgpairs@((+ i.)/)"1 > (1e6*i.1e3),.1e6+999>i.1e3 > > |limit error: dgpairs > > ... but p: doesn't work for values like 1e9 (1 p: works, but not p: > itself). > > And, for example, Roger has worked out some ways of dealing with large > primes -- see looking at > http://code.jsoftware.com/wiki/Essays/Primality_Tests -- but we don't have > anything that's a drop in replacement for the p: monad. > > So this presents something of a problem - how would we tackle a problem > like this? > > (Please feel free to change forum to programming if you've got working code > rather than just ideas...). > > Thanks, > > -- > Raul > > > > > On Tue, Mar 15, 2016 at 7:02 AM, Cliff Reiter <[email protected]> > wrote: > > > A look at the frequencies of pairs of last digits of successive primes: > > /:~({.,#)/.~2]\10|p:4+i.1e7 > > > > 1 1 446808 > > > > 1 3 756071 > > > > 1 7 769924 > > > > 1 9 526953 > > > > 3 1 593196 > > > > 3 3 422302 > > > > 3 7 714795 > > > > 3 9 769915 > > > > 7 1 639383 > > > > 7 3 681759 > > > > 7 7 422289 > > > > 7 9 756852 > > > > 9 1 820369 > > > > 9 3 640076 > > > > 9 7 593275 > > > > 9 9 446032 > > > > The 1 follows 1 as rare as 9 follows 9, but rarer is 3 follows 3 as rare > > as 7 follows 7. 9 1 most popular! Very curious. Probably should move to > > JProg' Best, Cliff > > > > > > > > > > On 3/14/2016 12:03 PM, R.E. Boss wrote: > > > >> > >> > https://www.quantamagazine.org/20160313-mathematicians-discover-prime-conspiracy/ > >> R.E. Boss > >> ---------------------------------------------------------------------- > For > >> information about J forums see http://www.jsoftware.com/forums.htm > >> > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
