forked from Annex5061/java-algorithms
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisarium.java
More file actions
Latest commit
21 lines (20 loc) · 579 Bytes
/
Copy pathDisarium.java
File metadata and controls
21 lines (20 loc) · 579 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importjava.util.*;
publicclassDisarium{
booleanisDisarium(intn){
bytec=0;
intb=0;
for(inti=n;i>0;c+=1,i/=10);
for(inti=n;i>0;b=b+(int)Math.pow(i%10,c--),i/=10);
if(n==b)
returntrue;
returnfalse;
}
publicstaticvoidmain(Stringargs[])
{
System.out.println("Enter a number:");
if(newDisarium().isDisarium(newScanner(System.in).nextInt()))
System.out.println("Disarium number");
else
System.out.println("Not an Disarium number.");
}
}