Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Where does your "50" come from? Don't forget that a number of inhabitants is an integer.

  • Custom User Avatar
    1. Always mark your solutions as spoiler (even if they are faulty, they have a lot of spoilers)
    2. You are breaking the loop before j = False gets executed. So, j is never False. And your function fails.
  • Custom User Avatar

    We were answering simultaneously CrazyMerlin. Sorry for that!

  • Custom User Avatar

    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!!

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution