What is an Armstrong Number?
The number for which the sum of its digits to power of number of its digits is equal to that number is known as an Armstrong Number.
For example, a numbers for which the sum of cube of its digits is equal to that number is an Armstrong number.
153 is such a number since 1 cubed 3 + 5 cubed 3 + 3 cubed 3 = 153.
GET INSTANT HELP FROM EXPERTS!
- Looking for any kind of help on your academic work (essay, assignment, project)?
- Want us to review, proofread or tidy up your work?
- Want a helping hand so that you can focus on the more important tasks?
Hire us as project guide/assistant. Contact us for more information
Another example is 1634.
Total digits in 1634 is 4.
And 1 to the power of 4 + 6 to the power of 4 + 3 to the power of 4 + 4 to the power of 4 = 1634.
More examples of Armstrong numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 372, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834, 1741725
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) + ….
Write a Computer Program:
Write a program to check whether the entered number is Armstrong or not.
Example 1: Check Armstrong Number for 3 digit number
public class Armstrong {
public static void main(String[] args) {
int number = 371, originalNumber, remainder, result = 0;
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber % 10;
result += Math.pow(remainder, 3);
originalNumber /= 10;
}
if(result == number)
System.out.println(number + ” is an Armstrong number.”);
else
System.out.println(number + ” is not an Armstrong number.”);
}
}
StudyMumbai.com is an educational resource for students, parents, and teachers, with special focus on Mumbai. Our staff includes educators with several years of experience. Our mission is to simplify learning and to provide free education. Read more about us.
Leave a Reply
You must be logged in to post a comment.