Check Armstrong number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Check Armstrong number

Write a program which checks if a number is Armstrong or not. Armstrong number is a number which is equal to sum of digits raise to the power total number of digits in the number. Some Armstrong numbers are: 0, 1, 4, 5, 9, 153, 371, 407, 8208 etc. For example :153 1^3 +5^3 +3^3=153(Armstrong number) Any language is welcomed Thumbs up my question if you like it.. Happy coding :)

17th Oct 2017, 11:43 AM
Chinmoy
Chinmoy - avatar
8 Answers
17th Oct 2017, 3:41 PM
Vukan
Vukan - avatar
+ 12
https://code.sololearn.com/cTUMw4i9B7KJ/?ref=app
17th Oct 2017, 11:53 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 10
@Chinmoy it's fix now for any number
17th Oct 2017, 12:56 PM
GAWEN STEASY
GAWEN STEASY - avatar
17th Oct 2017, 12:51 PM
qwerty
qwerty - avatar
+ 5
https://code.sololearn.com/c70l69xJWNzK/?ref=app A one-liner solution (actually 2)
17th Oct 2017, 12:17 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
Please, this has been asked several rimes. But I haven't tried once, so I shall go ahead
17th Oct 2017, 12:15 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
GAWEN there's only one problem with your code it will only work if the length of entered number is 3..... Like if I enter 8208 or 9 it won't work... Read the question again :)
17th Oct 2017, 11:57 AM
Chinmoy
Chinmoy - avatar
28th Feb 2018, 8:14 AM
Misak Poghosyan
Misak Poghosyan - avatar