문제
번역본 보기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에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.