We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!Submit Feedback
@PaulFound Sounds a little slow. My solution generates primes up to 1,000,000 in 55 seconds.
(I did make a small optimisation to get it under 1 minute which means it does not find 2 as prime, but does find the 78,497 others).
Here's mine - it doesn't scale very well but it works fine for numbers up to 50. It can calculate up to 10,000 in about 35 seconds but I wouldn't want to push it much further as it's comparing all possible combinations.
Did it again, spot-checking the first several primes in Alteryx, and using an R package that can handle very large numbers... I ran it again on 1 - 1,000,000, and also added in a bunch of very large numbers for kicks.
These are the added numbers:
1234567890 12345678901 123456789012 1234567890123 12345678901234 123456789012345 1234567890123456 12345678901234567 123456789012345678 1234567890123456789 12345678901234567890 123456789012345678901 1234567890123456789012 12345678901234567890123 123456789012345678901234567 1234567890123456789012345678901 123456789012345678901234567890123 1234567890123456789012345678901234567 12345678901234567890123456789012345678901 170141183460469231731687303715884105727 20988936657440586486151264256610222593863921
With the spot checking, it's down to about 25 seconds or so.