Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def perfect_number(x):
- divisors = [num for num in range(1, x // 2 + 1) if x % num == 0]
- sum = 0
- for divisor in divisors:
- sum = sum + divisor
- if sum == x:
- return "The number {} is perfect".format(x)
- else:
- return "The number {} is not perfect".format(x)
- if __name__ == "__main__":
- broj = eval(input())
- print(perfect_number(broj))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement