본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 6975번 Deficient, Perfect, and Abundant

by 현장 2024. 8. 25.

-Code

for _ in range(int(input())):
    n = int(input())
    measure = []

    for i in range(1, n // 2 + 1):
        if n % i == 0:
            measure.append(i)

    sum_measure = sum(measure)
    res = "is a perfect number."
    if sum_measure > n:
        res = "is an abundant number."
    elif sum_measure < n:
        res = "is a deficient number."

    print(f"{n} {res}")
    print()