Advertisement
Spocoman

10. Perfect Number

Jan 28th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. num = int(input())
  2.  
  3.  
  4. def solve(n):
  5.     sum_div = 0
  6.     for i in range(1, n):
  7.         if n % i == 0:
  8.             sum_div += i
  9.     return f"We have a perfect number!" if sum_div == n else "It's not so perfect."
  10.  
  11.  
  12. print(solve(num))
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement