-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDisariumNumber.java
More file actions
26 lines (23 loc) · 812 Bytes
/
Copy pathDisariumNumber.java
File metadata and controls
26 lines (23 loc) · 812 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
import java.util.*;// package name added
public class Example11 {
public static void main(String args[]);
{
Scanner sc = new Scanner(System.in)
System.out.print("Input a number : ");
int num = sc.nextInt();
int copy = num, d = 0, sum = 0;
String s=Integer.toString(num); // integer converted to string
int len = s.length();
while(copy>0)
{
d = copy % 10;
sum = sum + (int)Math.pow(d,len);
len--;
copy = copy / 10;
}
if(sum == num)
System.out.println("Disarium Number.");
else
System.out.println("Not a Disarium Number.");
}
}