Cody Problems 1012 and 2544 ask us to determine whether a number n is perfect—that is, whether the sum of divisors sigma(n) is equal to 2n
. 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 d', sigma(n) - 2d' = 2n. 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

6 Solutions

4 Solvers

Last Solution submitted on Mar 16, 2026

Last 200 Solutions

Solution Comments

Show comments
Loading...

Problem Recent Solvers4

Suggested Problems

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!