community
cancel
Showing results for 
Search instead for 
Did you mean: 
Do you have the skills to make it to the top? Subscribe to our weekly challenges. Try your best to solve the problem, share your solution, and see how others tackled the same problem. We share our answer too.
Weekly Challenge
Do you have the skills to make it to the top? Subscribe to our weekly challenges. Try your best to solve the problem, share your solution, and see how others tackled the same problem. We share our answer too.
Unable to display your progress at this time. Please try again a little later, or contact an administrator if you continue to see this error.
Getting started with Designer? | Start your journey with our new Learning Path!

Challenge #187: Generate Prime Numbers

Here's my solution using Generate Row Numbers

My solution, it's not particularly scalable though.

Quasar

Interesting challenge.

Alteryx Certified Partner

And sometimes a little bit of code makes performance much better!

 

KoenVerhagen_0-1572444396099.png

 

When using the python tool, performance is not that much of an issue.

 

Determining the primes upto 1Mio only takes 13 seconds.

Magnetar
Magnetar

My solution! It's been a while... I have some catching up to do!!

 

Spoiler
WeeklyChallenge187.JPGWeeklyChallenge187Result.JPG

Cheers! 

NJ

Asteroid

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

Meteoroid

Hi there,

 

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.

 

Spoiler
lcrosby_0-1572454445126.png

My solution! 

ACE Emeritus
ACE Emeritus

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.

Spoiler

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.

JohnJPS_0-1572468895300.png  
Meteoroid

Solved with If / Then....

 

.... then I saw a use of Modulo in a spoiler, so I decided to learn about this function and was able to come up with a solution with Modulo as well.  Good learning exercise.

 

Dan