about | help | code help+videos | done | prefs |
Write a method that accepts a positive integer input parameter in the range of 2 to 2000. The method returns the distance to the nearest prime number less than or equal to the input parameter. So nearestPrime(8) returns 1 because the nearest prime less than or equal to 8 is 7, which is one less than 8. nearestPrime(11) returns 0 because 11 is prime so the nearest prime is 0 away. nearestPrime(22) → 3 nearestPrime(258) → 1 nearestPrime(1025) → 4 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 440
Copyright Nick Parlante 2017 - privacy