diff --git a/solutions/python/perfect-numbers/1/perfect_numbers.py b/solutions/python/perfect-numbers/1/perfect_numbers.py new file mode 100644 index 0000000..809faf9 --- /dev/null +++ b/solutions/python/perfect-numbers/1/perfect_numbers.py @@ -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 < 1: + raise ValueError("Classification is only possible for positive integers.") + copy_num = number + aliquot = 0 + for i in range(1, copy_num): + if copy_num % i == 0: + aliquot += i + if aliquot == copy_num: + return "perfect" + elif aliquot < copy_num: + return ("deficient") + else: + return "abundant" + #classify(15) \ No newline at end of file