My issue
hidden test casesfailed
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
int order(int x){
int n = 0;
while (x != 0) {
n++;
x = x / 10;
}
if(n<=10){
return n;
}
else{
return -1;
}
}
void isArmstrong(int x){
int m= order(x);
int r=0;
double sum=0;
int temp=x;
while(temp!=0){
r=r%10;
sum= sum+Math.pow(r,m);
temp=temp/10;
}
if(x==sum){
System.out.println("Armstrong");
}
else{
System.out.println("Not Armstrong");
}
}
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc =new Scanner(System.in);
int x=sc.nextInt();
Codechef ob = new Codechef();
ob.isArmstrong(x);
}
}
Learning course: Roadmap to 3*
Problem Link: https://www.codechef.com/learn/course/rcpit-roadmap-3star/RCPITRMT01/problems/LPYAS151