A disarium number is a number in which the sum of the digits to the power of their respective position is equal to the number itself .
import java.util.*; import java.lang.*; class disariumTest { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter Number: "); int num = sc.nextInt(); String s = Integer.toString(num); int l = s.length(); int n = num; double c = 0; int last_digit; while(num > 0) { last_digit = num % 10; c = c + Math.pow(last_digit,l); num = num / 10; l--; } if(n == c) { System.out.println("Disarium Number."); } else { System.out.println("Not a Disarium Number."); } sc.close(); } }