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

Meteoroid

Very interesting challenge - I'm sure everyone went about it in a different way. Here's mine:

 

Spoiler
fguardini_2-1572352033608.png

I calculated the root of the input number, 50, to get the list of integers to use for testing - 2 to 7. I created the list of numbers to be tested, 2 to 50. I excluded the single-integer prime numbers for simplicity. For the others, I checked which ones have a remainder when divided by one of the numbers between 2 and 7. I joined the two lists for a full list of integer numbers between 2 and 50.

One step includes removing numbers equals to the dividends, this makes the workflow usable for very large numbers as well. It's still quite fast with numbers in the thousands

Alteryx Certified Partner

A fun challenge for sure! Great to approach these fundamental concepts through the lense of Alteryx. 

 

Spoiler
187.png
Asteroid

Hi Christine,

 

 

 

please find attached my solution.

 

Spoiler
Kucsi_0-1572353756203.png

 

Thanks,

Kucsi

Nebula
Nebula

Good challenge. Here's an iterative macro implementation of the Sieve of Eratosthenes.  The trade off is speed vs memory use by not requiring the X join at the start that the divisor method requires.  The table is never bigger that N-1 rows but gets iterated over once for every prime less than SQRT(N)

Spoiler
m.png



Dan

 

 

 

 

Meteor

Here is my solution!

 

Spoiler
s.PNG
Alteryx Certified Partner

Hi!

I tried to minimize the number of checks.

 

As there is only 1 odd prime, which is 2, I decreased the generate rows by the following loop expression:
if Number < 3 then Number + 1 else Number+ 2 endif.

 

Further the range which we need to check if a division can be made starts with 3
(no uneven number can be divided by 2, and is maximized on 1/3 * [number].

 

So as you can see in the workflow, it works quite fast.
But even then finding all the primes under 25000 generates around 26 mio checks!

 

 

Asteroid

Hi! Here my solution

Meteoroid
 
Bolide

Fun challenge! Definitely curious to see how others did this as I don't think my solution is the most efficient.

Spoiler
Challenge 187.PNG
Asteroid

Here is my solution