Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getAllDivisors(n):
- ret=[1]
- i=2
- while i<n:
- if (n%i)==0:
- ret.append(i)
- i+=1
- return ret
- def isPerfect(n,s):
- return n==s
- def isAbundant(n,s):
- return s>n
- def isAmicable(n,s):
- l=getAllDivisors(s)
- s2=sum(l)
- return s2==n
- def whatKindOfNumber(n):
- l=getAllDivisors(n)
- s=sum(l)
- if isPerfect(n,s):
- return "perfect"
- ret=""
- if isAbundant(n,s):
- ret+="abundant"
- else:
- ret+="deficient"
- if isAmicable(n,s):
- ret+=",amicable"
- return ret
- def main():
- print("categorize.py")
- print("Developed by: Pedro Izecksohn")
- n=int(input("Enter an integer>1:"))
- if n<=1:
- print("Invalid number")
- return
- print(whatKindOfNumber(n))
- return
- if __name__=="__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment