From d58f8ca94e87e9319409db323ce6282019070bc6 Mon Sep 17 00:00:00 2001 From: sourav das <91898457+sourav153@users.noreply.github.com> Date: Tue, 5 Oct 2021 17:11:39 +0530 Subject: [PATCH] armstrong number check --- armstrongNumber.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 armstrongNumber.py diff --git a/armstrongNumber.py b/armstrongNumber.py new file mode 100644 index 0000000..a988381 --- /dev/null +++ b/armstrongNumber.py @@ -0,0 +1,20 @@ +# Python program to check if the number is an Armstrong number or not + +# take input from the user +num = int(input("Enter a number: ")) + +# initialize sum +sum = 0 + +# find the sum of the cube of each digit +temp = num +while temp > 0: + digit = temp % 10 + sum += digit ** 3 + temp //= 10 + +# display the result +if num == sum: + print(num,"is an Armstrong number") +else: + print(num,"is not an Armstrong number")