hermann on Tue, 06 Jan 2026 09:31:01 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

isprime() runtime jump between 10^18 and 10^20?


I recently submitted https://oeis.org/draft/A392244 on "Number of primes of the form b^2 + (b+1)^2 for b <= 10^n.".

PROG section has this straightforward PARI script:

a(n)=sum(k=1, 10^n, isprime(k^2+(k+1)^2));

It is quite fast for up to n=9 (5 minutes on AMD 7950X CPU). And it computed a(10) as well, but did need 23h for that:

? a(10)

cpu time = 33h, 53min, 56,970 ms, real time = 23h, 3min, 55,987 ms.
614983774
?

So is there an isprime() runtime jump between 10^18 and 10^20?


There is a conjecture that pi_{k^2+1)(10^n) is a minorant of pi(10^n) = pi_{k}(10^n), with limit factor of 0.686413 (https://oeis.org/A206709).

New sequence conjecture is lim_{k->oo} pi_{k^2+(k+1)^2}/pi_{k^2+1} = 2, so p_{k^2+(k+1)^2} is majorant of prime counting funtions pi(). There are much more primes for k<=10^n in k^2+(k+1)^2 than in natural numbers up to 10^k, which is confirmed by counts up to 10^11.


I did create a non-PARI C++ code that traverses a related great grandparent DAG for a "sieve of Eratosthenes like" sieving, which is described here:

https://gist.github.com/Hermann-SW/4b197c6e8bf9f65c7a074ad6271ddce4#file-parallel_dfs_bfs_evenly-cc-L26-L53

Sequential code did compute a(10) in 22min and first parallel version a(11) in 14:28h (on 192C/384T 8-socket server). The directed acyclic graph traversed contains all sum of successive squares composite numbers, allowing to sieve without prime test. Servers's 1TB ram allowed to have 100GB array for sieve. The height of that directed acyclic graph is 40% of 10^n, with is 40 billion(!) for n=11. I never had to traverse such a deep directed acyclic graph ...


Regards,

Hermann.