Challenge #79: Find the Closest Prime Number
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
12 - Quasar
01-19-2022
10:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
TonyAndriani
9 - Comet
04-28-2022
01:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Rwebber1991
8 - Asteroid
05-02-2022
07:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
binuacs
21 - Polaris
05-05-2022
05:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
SylwiaDragon
8 - Asteroid
05-19-2022
10:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
11 - Bolide
05-31-2022
08:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
scoles0617
8 - Asteroid
06-01-2022
06:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
13 - Pulsar
06-18-2022
01:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Super fun challenge!
My solution:
Spoiler
As I was building this I knew it was wildly inefficient... but it works. Now I'm going to RUN to go read all the brilliant submissions to this challenge.
I set the limit arbitrarily to a maximum of 10,000. If a number is equal distance from two prime numbers, it will return both.

I set the limit arbitrarily to a maximum of 10,000. If a number is equal distance from two prime numbers, it will return both.
17 - Castor
06-26-2022
12:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
My solution for #79. Not fully dynamic as it adopts the 6n +/- 1 approach, but a little strapped for time. In reality could just generate a full list of divisors based on generating rows from 1 to n where n is the number in question, and counting the number of times the number/divisor is 1.
aiahwieder
9 - Comet
07-13-2022
02:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator