PROGRAM TO IMPLEMENT ARMSTRONG NUMBER
import java.util.*;
import java.lang.Math;
import java.io.*;
class GFG {
public static void main (String[] args) {
Scanner s =new Scanner(System.in);
System.out.println("enter how many text cases do you want");
int n =s.nextInt();
int sum=0,rem,cube,temp;
for(int i=0;i<n;i++)
{int x=s.nextInt();
temp=x;
while(x!=0)
{
rem =x%10;
cube=(int) Math.pow(rem,3);
sum =sum +cube;
x=x / 10;
}
if(sum ==temp)
System.out.println("YES");
else
System.out.println("NO");
}
//code
}
}
import java.lang.Math;
import java.io.*;
class GFG {
public static void main (String[] args) {
Scanner s =new Scanner(System.in);
System.out.println("enter how many text cases do you want");
int n =s.nextInt();
int sum=0,rem,cube,temp;
for(int i=0;i<n;i++)
{int x=s.nextInt();
temp=x;
while(x!=0)
{
rem =x%10;
cube=(int) Math.pow(rem,3);
sum =sum +cube;
x=x / 10;
}
if(sum ==temp)
System.out.println("YES");
else
System.out.println("NO");
}
//code
}
}
Comments
Post a Comment