PARI9-5-07

PARI9-5-07 - 18.781 In-Class Discussion, September 5, 2007...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
18.781 In-Class Discussion, September 5, 2007 parisize = 4000000, primelimit = 500000 (13:42) gp > P(n)=c=1;for(k=2,n/2,if(isprime(2*k-1), c++));c (13:44) gp > P(5) %1 = 2 (13:44) gp > P(50) %2 = 15 (13:44) gp > P(500) %3 = 95 (13:45) gp > P(5000) %4 = 669 (13:45) gp > P(5*10^4) %5 = 5133 (13:45) gp > P(5*10^5) %6 = 41538 (13:45) gp > P(5*10^6) %7 = 348513 (13:47) gp > ## *** last result computed in 1mn, 41,340 ms. (13:47) gp > P(5*10^7) %8 = 3001134 (14:06) gp > ## *** last result computed in 18mn, 4,480 ms. In the calculation above, note that PARI knows a table of primes up to 500,000 (“primelimit”) so calculations with such primes are ultrafast. But for larger n , we are forced to define our own function, like P ( n ).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
We can slightly modify the program, defining a function L ( n ) to count the number of primes of the form 5 k + 2 which are less than n . GP/PARI CALCULATOR Version 2.1.6 (released) i686 running linux (ix86 kernel) 32-bit version (readline v4.3 enabled, extended help available)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

PARI9-5-07 - 18.781 In-Class Discussion, September 5, 2007...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online