forked from Annex5061/java-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Armstrong_Funtion.java
40 lines (37 loc) · 1.02 KB
/
Armstrong_Funtion.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.io.*;
class Armstrong_Funtion
{
public int Number(int n)
{
int r,a=0,ano=n,flag=0;
while(n>0)
{
r = n%10;
a = a + (r*r*r);
n = (n-r)/10;
}
if(ano==a)
flag = 1;
else
flag = 0;
return(flag);
}
public static void main(String args[]) throws IOException
{
System.out.println("Armstrong Number");
System.out.println("****************");
System.out.println("");
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
int d,p;
System.out.print("Enter Number : ");
d = Integer.parseInt(br.readLine());
System.out.println("");
Armstrong_Funtion ob = new Armstrong_Funtion();
p = ob.Number(d);
if(p==1)
System.out.println("Number is Armstrong");
else
System.out.println("Number is Not Armstrong");
}
}