Alle Herausforderungen
Einfach 0 gelöst 0% Erfolgsquote

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.

Einschränkungen

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

Beispiele

Beispiel 1
Eingabe:
n = 18

Erwartete Ausgabe:
expected = "abundant"
Eingabe:
long long n = 18;

Erwartete Ausgabe:
std::string expected = "abundant";
Eingabe:
long n = 18;

Erwartete Ausgabe:
string expected = "abundant";

Erläuterung

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

Beispiel 2
Eingabe:
n = 28

Erwartete Ausgabe:
expected = "perfect"
Eingabe:
long long n = 28;

Erwartete Ausgabe:
std::string expected = "perfect";
Eingabe:
long n = 28;

Erwartete Ausgabe:
string expected = "perfect";

Erläuterung

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

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.