# Weekly Challenge

Solve the challenge, share your solution and summit the ranks of our Community!
New content is available in Academy! You may need to clear your browser cache for an optimal viewing experience

## Challenge #187: Generate Prime Numbers

Highlighted
Alteryx Certified Partner

A prime example of a good weekly challenge.

In one line of Python,

``[i for i in range(2,50) if 0 not in (i%j for j in range(2,i))]``

Otherwise,

Spoiler
Workflow

Code

Highlighted
Atom

Here's my solution

Spoiler
Highlighted
Meteor

This solution is very inefficient and generates a lot of waste data:

Spoiler
Highlighted
ACE Emeritus

@elliotyoung - I used the R tool here.

Highlighted
Fireball

No pretty, but I got there.

solution attached.

Asteroid

I liked this one!

Spoiler
Highlighted
Alteryx Partner

A good old sieve. 998 iterations in ~1 min for primes under 1 000 000 all in Alteryx

Spoiler
1. Main Workflow generates the rows and feeds the iterative macro, then filter primes2. Loop through the integers that are still prime until SQRT(Target) and flag whether number is divisible (discard) or not (keep)
Highlighted
Asteroid

Highlighted
Alteryx

Think my solution may be a little too simplistic, but it gets the job done! 2 tools.

Highlighted
Alteryx Partner

Here's my solution, it is based on trial division method. For very large numbers it will be slow to generate the data required but it will work.

Spoiler