You seem to confuse primes generator with primarily test. Sieves are not tests, they are prime generators. To test for a prime you do not need prime generators. You could use one, but not in the most trivial way of generating all primes up to N.
2000000000 is the maximum value tested in random tests in Python. On your computer you can only do the basic tests, which are easy and not numerous ones.
This is a very classic mathematical problem, and an easy 6 kyu kata. You need to use another method, make an online search and you'll find easily. Any hint we could give you would spoil the solution.
Just one thing: to find out if a number is prime, you don't need all the primes below it. Actually you don't need any of them, you just need to check... it's prime.
You seem to confuse primes generator with primarily test. Sieves are not tests, they are prime generators. To test for a prime you do not need prime generators. You could use one, but not in the most trivial way of generating all primes up to N.
2000000000 is the maximum value tested in random tests in Python. On your computer you can only do the basic tests, which are easy and not numerous ones.
@akar-0: I guess Eratostenes never thought of calculating such high numbers :S thx for the hint.
This is a very classic mathematical problem, and an easy 6 kyu kata. You need to use another method, make an online search and you'll find easily. Any hint we could give you would spoil the solution.
Just one thing: to find out if a number is prime, you don't need all the primes below it. Actually you don't need any of them, you just need to check... it's prime.
Try a few tests with
n = 2000000000
or similar.thx for the link, but you can help me to understand why? in my machine "execution time : 0.021 s" and tests here allways says under 600ms.
Don't spoil solution on discourse page, thanks.
Your approach is very inefficient. This is not a kata issue. See there: https://docs.codewars.com/training/troubleshooting/
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution