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

KilianL
Alteryx Alumni (Retired)

I went for testing all combinations of dividend and divisors and then checking if it meets prime conditions.

 

Spoiler
187 - Find Prime Numbers - Kilian.png
robert-headington
8 - Asteroid
Spoiler
187.PNG

At first, I got the solution by checking if each number lower than the number you are checking is a divider. However, this solution means that you are dividing my extra numbers (eg. if it's divisible by 4 is has to be divisible by 2) which I didn't like.

 

So I changed it to an iterative macro that only divides by prime numbers lower than the number you are checking. This makes it a lot faster when looking for all the prime numbers up to higher numbers (although it still does get slower the higher you go as it needs to divide by more primes). Due to iterative macros having a maximum of 10,000,000 iterations, the highest number this can currently check is 10,000,001 (as we don't check 1).

 

You could further improve this by dividing by a prime number then stopping if it was a divider by putting another iterative macro it this macro and adjusting the logic a little. I might do that another day.

apathetichell
18 - Pollux

I'm sure there is an iterative macro which is much much cleaner than this - but this works...

Luke_C
17 - Castor
Spoiler
Luke_C_0-1616610278050.png

 

rcarog
8 - Asteroid

Solution attached.

mpennington
11 - Bolide

Fun one. I believe this would be the second prime number challenge I have done, other one was find the nearest .  This one is a bit leaner. 

 

Spoiler
MP 187.jpg
DaisukeTsuchiya
13 - Pulsar
Spoiler
キャプチャ.JPG

JasonHu
8 - Asteroid
Spoiler
workflow.png

Here is my submission.

ABAsseged
7 - Meteor
Spoiler
ABAsseged_0-1620670254134.png

got to learn about the Mod function😎

byagelski
8 - Asteroid

my solution