問題
翻訳を表示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.
制約
1 ≤ n ≤ 1,000,000. Zero and negative values are excluded.
例
入力:
n = 18
期待される出力:
expected = "abundant"
入力:
long long n = 18;
期待される出力:
std::string expected = "abundant";
入力:
long n = 18;
期待される出力:
string expected = "abundant";
解説
The proper divisors are 1, 2, 3, 6, and 9. Their sum is 21, greater than 18.
入力:
n = 28
期待される出力:
expected = "perfect"
入力:
long long n = 28;
期待される出力:
std::string expected = "perfect";
入力:
long n = 28;
期待される出力:
string expected = "perfect";
解説
The proper divisors sum to 1 + 2 + 4 + 7 + 14 = 28, exactly the number itself.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。