Java Program to Check if Armstrong Number

In this post we’ll see a Java program to check if the passed number is an Armstrong number or not. A number is an Armstrong number if it is equal to the number you get by raising every digit of the number to the power of count of digits in the number and adding them.

As example

371 = 33 + 73 + 13 = 27 + 343 +1 = 371

Number of digits is 3 here so every digit is raised to the power of 3 and added. Since the calculated number is equal to the original number so 371 is an Armstrong number.

1634 = 14 + 6 4 + 34 + 44 = 1 + 1296 + 81 + 256 = 1634

Java code to check if number Armstrong number or not

Output

That’s all for the topic Java Program to Check if Armstrong Number. If something is missing or you have something to share about the topic please write a comment.


You may also like

One Comment

  1. Pingback: Java Program to Check if The Given Strings Are Anagram or Not - KnpCode

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.