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 #79: Find the Closest Prime Number

Nicholas_Bignell
8 - Asteroid
Simonvm9114
8 - Asteroid

Here's my solution

 

Spoiler
Simonvm9114_0-1581947259683.png

 

johnemery
11 - Bolide

I really enjoyed this challenge. The "mathy" ones are always fun for me.

 

There are three potential cases here:

  1. The given number is prime → outputs the same number.
  2. The closest primes above and below the number are different distances from the number → output the closest.
  3. The closest primes above and below the number are the same distance from the number → concatenate both into a comma-separated list.
Spoiler
Like most others, I built an iterative macro. It starts at the given number and counts one step up and down per iteration, checking each new value for primality. This could certainly be made much more efficient by paying attention to the parity of the given number, storing previously known primes from prior iterations, and so on.

Macro Capture.PNGSolution Capture.PNG
dashakir1
8 - Asteroid

Thanks JoeM.

LindaLo
8 - Asteroid

Check out my solution!

It has one constraint that I only check numbers up 10000

And it allows to output more than one closest prime number to the input in case the difference between previous/ next Prime and Input is the same. 

atcodedog05
22 - Nova
22 - Nova

On a spree to binge complete weekly challenges
Adrenaline rush

 

I solved it using python tool

atcodedog05_0-1585475887060.png

 

Spoiler
This is my solution
atcodedog05_0-1585475749604.png

 

Check the workflow flow for the python code

 

AndrewS
11 - Bolide

#79

Spoiler
AppAppResultResult
Jonathan-Sherman
15 - Aurora
15 - Aurora

Challenge 79 is done!

 

Spoiler
So i went with an two iterative macro solution...and gave the option for the user to see both numbers or just the closest!

Interface:
Interface App.PNG

Workflow:
App Workflow.PNG

Macro:
Standard Macro.PNG

Iterative Macro:
Iterative Macro.PNG
AngelosPachis
16 - Nebula

My solution for challenge #79

 

Spoiler
Annotation 2020-05-12 211744.png
AlexC2
8 - Asteroid

solution attached.