Example 30: Armstrong Numbers
Learn how to print Armstrong numbers.
We'll cover the following
Problem
If the sum of cubes of each digit of the number is equal to the number itself, the number is called an Armstrong number. For instance,
Write a program to print out all Armstrong numbers between 1 and 500.
Examples
Input | Output |
---|---|
Nil | 1 153 370 371 407 |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.