From bc00907b739f2dc81e75fff15910cbc51e97485c Mon Sep 17 00:00:00 2001 From: Vamsi Krishna <33099230+V-V-K@users.noreply.github.com> Date: Tue, 9 Oct 2018 21:13:21 +0530 Subject: [PATCH] Update 5.py Hey, the program you wrote was in C++. But no worries, I have got the code up and running in Python. Cheers. --- 5.py | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/5.py b/5.py index d53b77a..00ff2cf 100644 --- a/5.py +++ b/5.py @@ -1,25 +1,13 @@ -#include -using namespace std; - -int main() -{ - int origNum, num, rem, sum = 0; - cout << "Enter a positive integer: "; - cin >> origNum; - - num = origNum; - - while(num != 0) - { - rem = num % 10; - sum += rem * rem * rem; - num /= 10; - } - - if(sum == origNum) - cout << origNum << " is an Armstrong number."; - else - cout << origNum << " is not an Armstrong number."; - - return 0; -} +#Armstrong number check upto 3 digits only +origNum = int(input("Enter a positive integer: ")) +num = origNum; +sum=0 +while(num != 0): + rem = num % 10 + sum += rem ** 3 + num //= 10 + +if(sum == origNum): + print(origNum," is an Armstrong number.") +else: + print(origNum," is not an Armstrong number.")