Karim Belabas on Sun, 25 May 2014 13:14:28 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: bug in PARI/GP (Segmentation Fault), please report. |
* John W. Nicholson [2014-05-25 12:55]: [..] > n=2;while(ln(prime(n))>ln(prime(n+1))/exp(1/(n))&&n<pl,n++);print(n) > *** at top-level: ...=2;while(ln(prime(n))>ln(prime(n+1))/exp(1/(n > *** ^-------------------- > *** prime: bug in PARI/GP (Segmentation Fault), please report. > *** Break loop: type 'break' to go back to GP prompt > break> n > 23163299 > break> > > Is this a bug on my machine, or can it be reproduced by others? Has this been reported before? Can you try to narrow it down ? With n = 23163299 N = n + 1 alias(ln, log) I can't reproduce it: the following command runs to completion while(ln(prime(n))>ln(prime(n+1))/exp(1/(n))&&n<N,n++); Cheers, K.B. P.S. Your program is inefficient: prime(n) runs in time O(n), so it runs in time O~(N^2). Also (minor) prime(n+1) doesn't use the previously computed prime(n). Much better: test(N) = { n = 1; logprev = log(2); forprime(p = 3, N, my (l = log(p)); \\ l = log(prime(n+1)), logprev = log(prime(n)) if (logprev*exp(1/n) < l, print([n, p])); logprev = l; n++; ); } Untested but runs in time O~(N). -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux1.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux1.fr/ [PARI/GP] `