alteryx Community

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

## Challenge #79: Find the Closest Prime Number

12 - Quasar

Solved

8 - Asteroid

solution attached

10 - Fireball

I just did a prime number challenge so I added some logic and made it into an app :D

Spoiler
8 - Asteroid

My solution attached.

Used two iterative macros, one that checks the numbers up 1000 and one that checks the numbers down 1000.

Checks include sum of digits divisible by 3, and difference in sum of alternating digits divisible by 11, and divisibility by 2 and 5.

Not perfect approach but gets the job done

8 - Asteroid

my solution! created two iterative macros to find closest prime preceding and succeeding the input number. then batched

8 - Asteroid

My solution - Implemented using two macros. Nice exposure to all types of macros.

8 - Asteroid

Solution attached below:

Spoiler
Opted to use the double iterative macro approach so that the looping can end early if a prime number is found rather than using a Generate Row based approach

Main app workflow:

First (outer) iterative macro:

Second (inner) iterative macro:

App input and output:
8 - Asteroid

Challenge 79