Parity of Pi(n)


I have found in june 1997 new and numerous strange algorithms in order to compute the parity of various arithmetic functions. These algorithms have allowed me to compute in particular the parity of the number of prime numbers below or equal to n for n > 1020, to check known values (New values of pi(x) : M. Deleglise et J. Rivat) , and to forecast the parity for new values of n.
The complexity of the algorithm is in O(n1/2*logn) with a storage space in O(1) !
You can find below the results of the computations already done of ppi(n)=pi(n) mod 2, in particular for n>= 1018 :
The computed parities confirm the known pi(n).

pi(n) 
ppi(n) 
1018  24 739 954 287 740 860 
2*1018  48 645 161 281 738 535 
3*1018  72 254 704 797 687 083 
4*1018  95 676 260 903 887 607 
5*1018  118 959 989 688 273 472 
6*1018  142 135 049 412 622 144 
7*1018  165 220 513 980 969 424 
8*1018  188 229 829 247 429 504 
9*1018  211 172 979 243 258 278 
1019  234 057 667 276 344 607 
2*1019  460 637 655 126 005 490 
3*1019  684 559 920 583 084 690 *
4*1019  906 790 515 105 576 571 
5*1019 
6*1019 
7*1019 
8*1019 
9*1019 
1020  2 220 819 602 560 918 840 
2*1020  4 374 267 703 076 959 271* 
3*1020  6 503 696 293 016 202 398 * 
4*1020  8 617 821 096 373 621 600 * 
5*1020  10 720 710 117 789 005 897 * 
6*1020 
7*1020 
8*1020 
9*1020 
1021  21 127 269 486 018 731 928* 
2*1021                                               ? 
10^22    
10^23    

 

 
We can also notice that ppi(n)+ppi(n-1)=1 if and only if n is prime, which can allow to test the primality of n.But unfortunately this test isn't very efficient (it is in O(n1/2*logn)).

* Last values of pi(n) found by Xavier Gourdon (november 2000) which confirm the parities I found (december 1997). Have a look at his site for explanations about the exact computing of pi(n).


Download the demonstration of the algorithm computing ppi(n).

Download a program computing ppi(n) for n<=1019.


Created by  Henri Lifchitz : September, 13  1998, last modification: May, 24  2001.