Cody Problems 1012 and 2544 ask us to determine whether a number n is perfect—that is, whether the sum of divisors
is equal to
. The number 28 is perfect because the sum of its divisors (1, 2, 4, 7, 14, and 28) is 56, or 2 times 28.
An admirable number is not quite perfect. For one of its proper divisors
,
. The number 30 is admirable because the sum of its divisors (1, 2, 3, 5, 6, 10, 15, 30) minus 2 times 6 is 60, or 2 times 30.
Write a function that takes a number x and finds the nearest admirable number. If two admirable numbers are equally close to x, take the smallest.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers4
Suggested Problems
-
Find the nearest admirable number
4 Solvers
More from this Author323
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!