forked from YashPatel1311/Finding-Prime-Numbers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrong
More file actions
32 lines (29 loc) · 686 Bytes
/
Armstrong
File metadata and controls
32 lines (29 loc) · 686 Bytes
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
import java.util.*;
class Armstrong
{
public static void main (String []args)
{
Scanner sc = new Scanner(System.in);
System.out.println("enter a number");
int n1 = sc.nextInt();
int temp = n1;
int n = temp;
// int temp =n1;
int rem=0,c=0,count=0;
while(n1 != 0)
{
n1=n1/10;
++count;
}
while(n>0)
{
rem=n%10;
n=n/10;
c=c+(int)Math.pow(rem,count);
}
if(temp==c)
System.out.println("entered number is Armstrong");
else
System.out.println("entered number is not Armstrong");
}
}