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.
.
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)