-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ5.java
More file actions
24 lines (23 loc) · 700 Bytes
/
Q5.java
File metadata and controls
24 lines (23 loc) · 700 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
import java.util.Scanner;
import java.lang.Math;
class Q5{
public static void main(String [] args)
{
Scanner ob = new Scanner(System.in);
System.out.println("Enter any number : ");
int num=ob.nextInt();
System.out.println("Enter the number of digits: ");
int count =ob.nextInt();
int temp = num,re,sum=0;
while(num!=0)
{
re=num%10;
sum+=(Math.pow(re,count));
num=num/10;
}
if(temp==sum)
System.out.println("YES,it is an Armstrong number.");
else
System.out.println("It is not an Armstrong number.");
}
}