Approximating π(n) using a sum of Tetrahedral (A000292) and Toric (A003600) sequences

16 views
Skip to first unread message

Yasser A. Chavez

unread,
Jan 16, 2026, 12:33:40 PM (4 days ago) Jan 16
to SeqFan
I was writing a pedagogical text about the Sieve of Eratosthenes and the prime-counting function, but I did not want to use the classic formulas. What began as a search for a modest formula for practical purposes led me to realize that, instead of subtracting the sequences, I had to sum them and, by multiplying by an adjustment factor, I could approximate the prime-counting function with a minimal margin of error.

The sequences involved are the tetrahedral numbers and the "maximum number of pieces obtained by slicing a torus (or a bagel) with n cuts", given by the formula (n^3 + 3*n^2 + 8*n)/6 for n > 0.

Endless thanks to N. J. A. Sloane and Mira Bernstein for making my text much more interesting.

I share the data for the interval 10^4 < π(n) < 2*10^5:

(k/50)*(A000292(n) + A003600(n-1)) ≈ π(A000292(n))

(3/50)*(10660+10699) = 1281.
pi(10660) = 1300.

(2.89/50)(20825+19648) = 2339.
pi(20825) = 2344.

(2.76/50)*(30856+29315) = 3321.
pi(30856) = 3327.

(2.67/50)*(41664+39772) = 4348.
pi(41664) = 4359.

(2.6/50)*(50116+47970) = 5100.
pi(50116) = 5145

(2.56/50)*(62196+59710) = 6241.
pi(62196) = 6251.

(2.52/50)*(70300+67598) = 6950.
pi(70300) = 6967.

(2.48/50)*(82160+79156) = 8001
pi(82160) = 8032

(2.45/50)*(91881+88640) = 8845
pi(91881) = 8877

(2.43/50)*(102340+98853) = 9777.
pi(102340) = 9802.

(2.4/50)*(113564+109822) = 10722.
pi(113564) = 10755.

(2.39/50)*(121485+117568) = 11426.
pi(121485) = 11432.

(2.36/50)*(134044+129857) = 12456.
pi(134044) = 12498.

(2.35/50)*(142880+138508) = 13225.
pi(142880) = 13255.

(2.34/50)(152096+147535) = 14022.
pi(152096) = 14034.

(2.32/50)*(161700+156946) = 14785.
pi(161700) = 14824.

(2.31)(171700+166749) = 15636.
pi(171700) = 15641.

(2.29/50)(182104+176952) = 16444. 
pi(182104) = 16503.

(2.28/50)(198485+193024) = 17852. 
pi(198485) = 17863.

(2.27/50)(204156+198590) = 18284.
pi(204156) = 18317.

Although, to be honest, I cannot fully understand why it works so well. Perhaps someone here with more advanced knowledge in geometry or topology could provide a more precise explanation.

Gareth McCaughan

unread,
Jan 16, 2026, 2:13:36 PM (4 days ago) Jan 16
to seq...@googlegroups.com, Yasser A. Chavez
On 16/01/2026 17:26, Yasser A. Chavez wrote:
> I was writing a pedagogical text about the Sieve of Eratosthenes and
> the prime-counting function, but I did not want to use the classic
> formulas. What began as a search for a modest formula for practical
> purposes led me to realize that, instead of subtracting the sequences,
> I had to sum them and, by multiplying by an adjustment factor, I could
> approximate the prime-counting function with a minimal margin of error.
>
> The sequences involved are the tetrahedral numbers and the "maximum
> number of pieces obtained by slicing a torus (or a bagel) with n
> cuts", given by the formula (n^3 + 3*n^2 + 8*n)/6 for n > 0.
>
> Endless thanks to N. J. A. Sloane and Mira Bernstein for making my
> text much more interesting.
>
> I share the data for the interval 10^4 < π(n) < 2*10^5:
>
> (k/50)*(A000292(n) + A003600(n-1)) ≈ π(A000292(n))

The thing you've called k doesn't seem to be constant -- you're putting
in a different value in every calculation below.

But if it doesn't have to be constant, you could just _define_ k = 50
pi(A000292(n)) / (A000292(n) + A003600(n-1)) and get _exact_ agreement!
And this would work no matter what the actual sequences were, so the
formula doesn't really tell you anything about the relationship between
those sequences and the prime-counting function.

Now, one thing that _isn't_ completely automatic is that over the range
of values you looked at, k doesn't change very much. But that's largely
because the required value changes slowly and the range you've looked at
is quite small. Suppose we take n = 1000. Then:

A000292(n) = 167167000
A003600(n-1) = 166667499
pi(A000292(n)) = 9353402

and so the value of k you need to make things work out is 50 x 9353402 /
(167167000 + 166667499) ~= 1.4. That's quite a lot smaller than the
values in your calculations. For larger n it will continue to decrease.

More generally, for large n the values of those two sequences are both
approximately n^3/6; call this N; then your formula says pi(N) ~=
k/25.N; what actually happens for large N is pi(N) ~= N/log(N), so the
value of k you need is about 25/log(N). In fact a slightly better
approximation is pi(N) ~= N/(log(N)-1) so better to take k = 25/(log(N)-1).

(note: these are _natural_ logarithms, not base-10 ones)

So e.g. when N=10^5 (where your examples suggest k ~= 2.43) we have
log(N) ~= 11.5, so 25/(log(N)-1) ~= 2.38; the agreement isn't perfect
but N is still fairly small here. When n=1000 and so N ~= 10^9/6, we
have 25/(log(N)-1) ~= 1.39 versus the 1.4 I found above.

So you could, if you wanted, replace "k" with "25/(log(A000292(n))-1)"
in your formula and get something that's approximately true for all n,
and gets better as n gets larger. But the only facts about A000292 and
A003600 that this would be relying on are (1) they get large for large n
and (2) for large n they are (relatively) very close to one another.

--
g

Yasser A. Chavez

unread,
Jan 16, 2026, 2:41:08 PM (4 days ago) Jan 16
to SeqFan
Now I understand how sequences can be adjusted to approximate π(n). My approach was more of a personal preference: by subtracting the tetrahedral numbers from π(n), I obtained the torus sequence, and I was able to verify that they are practically sister sequences. I also thank you very much for the approximation to k.
Reply all
Reply to author
Forward
0 new messages