import java.io.*;
class armstrong_number
{
public static void armstrong() throws IOException
{
int r,p,sum=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in) );
System.out.println("please enter the number");
int n=Integer.parseInt(br.readLine());
int no=n;
while(n>0)
{
r=n%10;
p=r*r*r;
sum=sum+p;
n=n/10;
}
if(sum ==no)
{
System.out.println("the no. is armstrong no.");
}
else
{
System.out.println("the no. is not a armsrong no.");
}
}
}
class armstrong_number
{
public static void armstrong() throws IOException
{
int r,p,sum=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in) );
System.out.println("please enter the number");
int n=Integer.parseInt(br.readLine());
int no=n;
while(n>0)
{
r=n%10;
p=r*r*r;
sum=sum+p;
n=n/10;
}
if(sum ==no)
{
System.out.println("the no. is armstrong no.");
}
else
{
System.out.println("the no. is not a armsrong no.");
}
}
}
No comments:
Post a Comment