Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Armstrong Number In Python
-
First of all here is the code:
#include<stdio.h> int fun(int); int main() { int x,a,b,y=0; printf("enter the number you want to identify is aN ARMSTRONG OR NOT:"); scanf("%d",&a); for(int i=1 ; i<=3 ; i++) { b = a % 10; x = fun(b); y = x+y; a = a/10; } if(y==a) printf("\narmstrong number"); else printf("\nnot an armstrong number"); return 0; } int fun(int x) { int a; a=x*x*x; return (a); }
I'm attempting to determine whether the number provided by the user is an armstrong number. Yet something is wrong, and I can't figure it out.
Any help is greatly appreciated.
-
Here is a PYTHON (not C as above) version with tests.
-
Given a number x, determine whether the given number is Armstrong number or not. A positive integer of n digits is called an Armstrong number of order n (order is number of digits) if.
abcd... = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ....
Example:
Input : 153
Output : Yes
153 is an Armstrong number.
111 + 555 + 333 = 153Input : 120
Output : No
120 is not a Armstrong number.
111 + 222 + 000 = 9Input : 1253
Output : No
1253 is not a Armstrong Number
1111 + 2222 + 5555 + 3333 = 723Input : 1634
Output : Yes
1111 + 6666 + 3333 + 4444 = 1634 -
ccc