We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My feeling is that there is no way to exactly know how many prime numbers there are less that a certain number without actually generating the prime numbers themselves. You can aproximate the number of primes but you would never be able to know exactly without generating the numbers. My reasoning behind this is that as far as I know there is currently no formula to generate the nth prime number and since there is no formula then there would be no way to accurately (that is exactly) say how many of them there are.
But I'm no mathematician, and I'm sure others on this forum are way smarter than I am and would be able to lead you in the proper directions or share some other insights. I'm just using plain old common sense in my reasoning above.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #187: Semiprimes
You are viewing a single comment's thread. Return to all comments →
This wiki article is quite comprehensive https://en.wikipedia.org/wiki/Prime-counting_function and also quite complex. Good luck on reading through it!!!
My feeling is that there is no way to exactly know how many prime numbers there are less that a certain number without actually generating the prime numbers themselves. You can aproximate the number of primes but you would never be able to know exactly without generating the numbers. My reasoning behind this is that as far as I know there is currently no formula to generate the nth prime number and since there is no formula then there would be no way to accurately (that is exactly) say how many of them there are.
But I'm no mathematician, and I'm sure others on this forum are way smarter than I am and would be able to lead you in the proper directions or share some other insights. I'm just using plain old common sense in my reasoning above.