With $f(n)=8n+8(n-1)+8(n-2)+\cdots+(8\cdot1)+1$, it is possible to calculate how many primes there are below $f(n)$ using $P(n)=\frac{n(n+1)}{2}+3n$.
Example:
When $n=3$, $f(3)=49$ and $P(3)=15$.
That means below 49 there are 15 primes.
It is also possible to know how many primes are between $f(x_1)$ and $f(x_0)$ using $p(x_1)-p(x_0)$
Is this a known formula? I tested this with a bunch of numbers I counted manually using Ulam Spiral. I would like to know whether my thinking is right.
How did I came to this conclusion:
I noticed that in Ulam Spiral every time the spiral goes around it contains exactly 8 more numbers than the last one and exactly one more prime number than the last round.
Example:
- first round (2-9) has 8 numbers and 4 primes
- second round (10-25) has 16 numbers and 5 primes
- third round (26-49) has 24 numbers and 6 primes
and so on.
Best Answer
This formula first fails at $n=7$, where it predicts $49$ primes below $225$ but in fact there are only $48$.
The error increases as $n$ increases, for example for $n=100$ the formula predicts $5350$ primes below $40401$ but there are actually only $4236$.