Ad
  • Custom User Avatar

    .

  • Custom User Avatar

    don't use a list for your primes if you use containment check, and remove (those are slow operations). Moreover, dont generate ALL the numbers up to n, you're ruining the use of what's in your condition for the while loop. Btw, archive the result of that function so that you don't compute if each time.

    All in all, you have to totally garbage your first for loop and the while one just after: merge them together, replacing the while with a more appropriate for loop (you'll still need the inner loop), and find a way to avoid the remove/in operations, somehow.

    Alternative: look up for prime generation algorithms.

    final note: don't forget the spoiler flag when you post code (even if wrong)

  • Default User Avatar

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