How to Create a Program to Check a Number is Armstrong Number or not in Core Java

In this tutorial how to  create a program to check a number is Armstrong number or not in Core Java  is shown.

Code:

Armstrong.java

class CheckArmstrong
{
public static void main(String args[])
{
int number=Integer.parseInt(args[0]),sum=0,r,copyn;
copyn=number;
while(copyn>0)
{
r=copyn%10;
sum+=(r*r*r);
copyn/=10;
}
if(sum==number)
System.out.println(number+” is Armstrong number”);
else
System.out.println(number+” is not Armstrong number”);
}
}

https://youtu.be/HMs0p_ZrcNc

Add a Comment

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