Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #187: Generate Prime Numbers

Flo_G
7 - Meteor

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 🙂

lmorrell
11 - Bolide

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

 

Spoiler
187.png
Kucsi
8 - Asteroid

Hi Christine,

 

 

 

please find attached my solution.

 

Spoiler
Kucsi_0-1572353756203.png

 

Thanks,

Kucsi

danilang
19 - Altair
19 - Altair

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

 

 

 

 

Vijuzy
8 - Asteroid

Here is my solution!

 

Spoiler
s.PNG

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!

 

 

RichoBsJ
11 - Bolide

Hi! Here my solution 🙂

cdavis19
7 - Meteor
 
cplewis90
13 - Pulsar
13 - Pulsar

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
pasccout
8 - Asteroid

Here is my solution