From d6cb90e76c4c7a2f270b622ca0cbf401f618db16 Mon Sep 17 00:00:00 2001 From: mapsid <44119524+mapsid@users.noreply.github.com> Date: Thu, 18 Oct 2018 19:35:58 +0530 Subject: [PATCH] Add files via upload Python code to find if a number is an Armstrong number. --- armstrong.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 armstrong.py diff --git a/armstrong.py b/armstrong.py new file mode 100644 index 0000000..1217717 --- /dev/null +++ b/armstrong.py @@ -0,0 +1,17 @@ +print("Enter a number") +answer=input() + +n=int(answer) +a=n +sum=0 +d=0 + +while n>0: + d=n%10 + sum=sum+d**3 + n=n/10 + +if sum==a: + print(a, "is an Armstrong number") +else: + print(a, "is not an armstrong number")