Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Where does your "50" come from? Don't forget that a number of inhabitants is an integer.
j = False
gets executed. So, j is never False. And your function fails.We were answering simultaneously CrazyMerlin. Sorry for that!
You're generating two lists of primes. Why? This will cost you a lot of time. When you have a problem of prime numbers you generally may have two situations:
you need a fast prime generator and in some cases to check if the number is prime, but will be used only once per run
you need a fast primality test checker like Miller - Rabin or others, this kind of test cost a lot of time. It should be used carefully and conveniently.
Try to optimize your code. Use spoiler to present your solutions!!
Calculating all primes below n will take too long no matter how much you accelerate it.
Maximum of the primes smaller than n is the one closest to it.
You don't need to check numbers lower than that.
This comment is hidden because it contains spoiler information about the solution