primeiro commit com exercicios de Exercism realizados até esta data

This commit is contained in:
2026-10-17 22:10:27 +01:00
commit 58fccbe27a
708 changed files with 35038 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
def classify(number):
"""A perfect number equals the sum of its positive divisors.
:param number: int a positive integer
:return: str the classification of the input integer
"""
if number <= 0:
raise ValueError(
"Classification is only possible for positive integers.")
aliquot_sum: int = 0
# find divisors and store them in a list
for divisor in range(1, (number // 2) + 1):
if not number % divisor:
aliquot_sum += divisor
if aliquot_sum == number:
return "perfect"
elif aliquot_sum > number:
return "abundant"
else:
return "deficient"