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

Rajesh_jain
5 - Atom

Here's my solution using Generate Row Numbers

wheedledee
5 - Atom

My solution, it's not particularly scalable though.

benakesh
12 - Quasar

Interesting challenge.

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. 🙂

NicoleJohnson
ACE Emeritus
ACE Emeritus

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

 

Spoiler
WeeklyChallenge187.JPGWeeklyChallenge187Result.JPG

Cheers! 

NJ

PaulRB
8 - 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).

lcrosby
7 - Meteor

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
Inactive User
Not applicable

My solution! 

JohnJPS
15 - Aurora

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  
dholle1958A
7 - Meteor

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