Cody Problem 241, which is based on Project Euler Problem 7, asks us to identify the Nth prime number. That is, the problem seeks the inverse of the prime counting function
, which provides the number of primes less than or equal to n. The Prime Number Theorem gives approximate forms of
for large n. Two such approximations are
and the offset logarithmic integral
, where
(See Cody Problem 46066).
Test these approximations by computing two ratios:
and
. Do not round the approximations to integers. For
, you will find that the first approximation is about 13% low and the second is about 16% high. However, for
, the first approximation is 6% low and the second is only 0.01% high.
Solution Stats
Problem Comments
4 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers18
Suggested Problems
-
Find common elements in matrix rows
2722 Solvers
-
The Hitchhiker's Guide to MATLAB
3429 Solvers
-
Test if a Number is a Palindrome without using any String Operations
259 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1294 Solvers
-
Hexagonal numbers on a spiral matrix
170 Solvers
More from this Author330
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Test added to discourage lookup table solutions.
In the problem description, r1 and r2 appear to be upside down.
Corrected. Thanks, Tim.
The upper bound of integration for li(x) should be x, not ∞.