From b83a2c765b6b46e6b7fa545f3323c02a56c42e8e Mon Sep 17 00:00:00 2001 From: Renuka Kamani Date: Sat, 25 Oct 2025 14:39:21 +0530 Subject: [PATCH 1/2] Added armstrong_number.py program for hactoberfest --- maths/armstrong_number.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 maths/armstrong_number.py diff --git a/maths/armstrong_number.py b/maths/armstrong_number.py new file mode 100644 index 000000000000..19c57bc95976 --- /dev/null +++ b/maths/armstrong_number.py @@ -0,0 +1,23 @@ +def is_armstrong(num: int) -> bool: + """ + Check if a number is an Armstrong number. + + Args: + num (int): Number to check + + Returns: + bool: True if Armstrong, False otherwise + """ + digits = str(num) + power = len(digits) + total = sum(int(digit) ** power for digit in digits) + return total == num + + +if __name__ == "__main__": # <-- corrected here + # Example usage + number = 153 + if is_armstrong(number): + print(f"{number} is an Armstrong number.") + else: + print(f"{number} is not an Armstrong number.") \ No newline at end of file From 8387a3787cfd1605af0977b9d1ed337bae10ff7a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 25 Oct 2025 09:14:01 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/armstrong_number.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/armstrong_number.py b/maths/armstrong_number.py index 19c57bc95976..9601357fdbf4 100644 --- a/maths/armstrong_number.py +++ b/maths/armstrong_number.py @@ -20,4 +20,4 @@ def is_armstrong(num: int) -> bool: if is_armstrong(number): print(f"{number} is an Armstrong number.") else: - print(f"{number} is not an Armstrong number.") \ No newline at end of file + print(f"{number} is not an Armstrong number.")