Problem 121774 · easy · Level 01 Prerequisites & Setup

Perfect, Abundant or Deficient

functions · divisors · conditionals

The proper divisors of n are all its positive divisors except n itself. Write classify_number(n) that returns:

  • "perfect" if the proper divisors add up to exactly n,
  • "abundant" if they add up to more than n,
  • "deficient" if they add up to less than n.

Examples

Input:  n = 6
Output: "perfect"
Explanation: 1 + 2 + 3 = 6.

Input:  n = 12
Output: "abundant"
Explanation: 1 + 2 + 3 + 4 + 6 = 16 > 12.

Input:  n = 8
Output: "deficient"

Constraints

  • 1 <= n <= 10**8
  • 1 has no proper divisors, so its sum is 0.

Goals

  • Sum the proper divisors of a number
  • Return one of several strings based on a comparison
Starting Python…