Tous les défis
Facile 0 résolus 0 % de réussite

Classify a Number by Its Divisors

Classify a positive integer as perfect, abundant, or deficient.

Add the positive divisors of n that are strictly smaller than n. If their sum equals n, the number is perfect. If the sum is larger, it is abundant; if smaller, it is deficient. The number 1 has no proper positive divisors, so its divisor sum is 0.

Implement perfect_number(n).

Input

n: The positive integer to classify.

Output

Return perfect, abundant, or deficient as lowercase text.

Contraintes

1 ≤ n ≤ 1,000,000. Zero and negative values are excluded.

Exemples

Exemple 1
Entrée :
n = 18

Sortie attendue :
expected = "abundant"
Entrée :
long long n = 18;

Sortie attendue :
std::string expected = "abundant";
Entrée :
long n = 18;

Sortie attendue :
string expected = "abundant";

Explication

The proper divisors are 1, 2, 3, 6, and 9. Their sum is 21, greater than 18.

Exemple 2
Entrée :
n = 28

Sortie attendue :
expected = "perfect"
Entrée :
long long n = 28;

Sortie attendue :
std::string expected = "perfect";
Entrée :
long n = 28;

Sortie attendue :
string expected = "perfect";

Explication

The proper divisors sum to 1 + 2 + 4 + 7 + 14 = 28, exactly the number itself.

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.