Sunday , 16 December 2018
Home » Class 10 » Java Program to check for Disarium Number

Java Program to check for Disarium Number


Write a Program in Java to input a number and check whether it is a Disarium Number or not.

Note: A number will be called DISARIUM if sum of its digits powered with their respective position is equal to the original number.

For example 135 is a DISARIUM
(Workings 11+32+53 = 135, some other DISARIUM are 89, 175, 518 etc)

Programming Code:

* The class Disarium inputs a number and checks whether
* it is a Disarium number or not
* @author :
* @Program Type : BlueJ Program - Java

class Disarium
    public static void main(String[] args)throws IOException
            BufferedReader br=new BufferedReader (new InputStreamReader(;
            System.out.print("Enter a number : ");
            int n = Integer.parseInt(br.readLine());
            int copy = n, d = 0, sum = 0;
            String s = Integer.toString(n); //converting the number into a String
            int len = s.length(); //finding the length of the number i.e. no.of digits
                d = copy % 10; //extracting the last digit
                sum = sum + (int)Math.pow(d,len);
                copy = copy / 10;
            if(sum == n)
                System.out.println(n+" is a Disarium Number.");
                System.out.println(n+" is not a Disarium Number.");


Enter a Number : 135
135 is a Disarium Number.

Enter a Number : 219
219 is not a Disarium Number.

Enter a Number : 89
89 is a Disarium Number.

Check Also

[Question 1] ISC 2017 Computer Practical Paper Solved – Box Packing

Solution of Program 1 of ISC 2017 Computer Science Paper 2 (Practical) Exam. Java program to input number of boxes to be packed and display the break-up of the cartons used in descending order of capacity


  1. Good and helpful for me

  2. S.Sulthan Mohiddin

    Yes please keep sending this type of interesting programs.

  3. please keep sending such interesting programs…..thank you

Leave a Reply to S.Sulthan Mohiddin Cancel reply

Your email address will not be published. Required fields are marked *