Problem 46117. Test approximations of the prime counting function
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
Solution Comments
Show commentsGroup

Easy Sequences Volume I
- 10 Problems
- 8 Finishers
- Easy Sequences 1: Find the index of an element
- Easy Sequences 2: Trigonometric function with integral input and output
- Easy Sequences 3: Prime 44-number Squares
- Easy Sequences 4: Eliminate the Days of Confusion
- Easy Sequences 5: Project Euler Problem 1 - Again!
- Easy Sequences 6: Coefficient sums of derivatives
- Easy Sequences 9: Faithful Pairs
- Easy Sequences 10: Sum of Cumsums of Fibonacci Sequence
- Easy Sequences 11: Factorial Digits without Trailing Zeros
- Easy Sequences 12: 50th Prime
Problem Recent Solvers15
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!