It turns out we're going to 1e8 for that rosettacode task, for the moment.

If something changes and we need the first 1e9 primes, I guess Roger's
suggestion of using a sieve (I would implement that using p: for
primes up through p:3401) would be the way to go.

That said, when I look at v2.c in the j implementation, I see a table
(ptt[]) that seems to be a part of the p: implementation. And I guess
the limit was rather arbitrary and relates to how big Roger felt that
table should be.

Thanks,

-- 
Raul


On Mon, Mar 21, 2016 at 8:31 PM, 'Jon Hough' via Chat
<[email protected]> wrote:
> Since p: has a limit (why is that, by the way? I have written a pi(x) 
> function using Miessel's formula in another language and it does grind to a 
> slowdown for values much larger than 1e7, so that might be the reason. I'm 
> assuming internally J uses Miessel or Lehmer's formula.),
> it might be better to "cheat" and just use a hardcoded value for pi(1e9).
>
> https://primes.utm.edu/howmany.html  (scroll down to table 1)
>
>
> Also, possibly the worst idea ever, why not iterate from 2 to 1e9 and do 
> prime tests and keep a record of the previously found prime to compare the 
> final digits with the next prime, and keep a record of the comparisons. 
> Probably hopelessly slow, and inefficient.
>
> --------------------------------------------
> On Tue, 3/22/16, Raul Miller <[email protected]> wrote:
>
>  Subject: Re: [Jchat] primes
>  To: "Chat forum" <[email protected]>
>  Date: Tuesday, March 22, 2016, 12:14 AM
>
>  Oh, I coded wrong. The
>  limit error was from p:, but I should not have been
>  feeding it the value 1e9.
>
>  Sometimes I wonder how I get anything
>  done...
>
>  Thanks,
>
>  --
>  Raul
>
>
>  On Mon, Mar
>  21, 2016 at 11:03 AM, Roger Hui <[email protected]>
>  wrote:
>
>  >
>  > it should be straightforward to do the extra credit
>  problem
>  >
>  > I should
>  have checked.  The extra credit problem is for 100,000,000
>  primes.
>  >
>  >    _1 p:
>  _1+2^31
>  > 105097564
>  >    p: 1e8
>  >
>  2038074751
>  >
>  > So the
>  limit error is not in p: .
>  >
>  >
>  >
>  >
>  >
>  >
>  > 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
>  >
>  ----------------------------------------------------------------------
>  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

Reply via email to