Kodekraftt
/Blog
/Disarium Number In Java Definition Examples And Complete Program
Join Early AccessContact UsPrivacy Policy
Java BasicsOOPsDSA with JavaQuizzesInterview Preparation

© 2026 KodeKraftt. All rights reserved.

Build smarter. Learn more. Innovate better.

Disarium Number in Java: Definition, Examples, and Complete Program

A detailed explanation of Disarium Numbers in Java with definition, examples, step-by-step logic, and a complete Java program. Ideal for beginners, students, and coding interview preparation.

Disarium Number in Java

A Disarium Number is a special number in which the sum of its digits, each raised to the power of their respective positions, equals the number itself. Disarium numbers are commonly asked in Java programming assignments and coding interviews because they test understanding of digit extraction and loop-based logic.

What Is a Disarium Number?

A number n with digits \(d_1, d_2, d_3...\) is called a Disarium Number if:

Sum = d₁¹ + d₂² + d₃³ + ...
If Sum == n → It is a Disarium Number
  

Examples

  • 135 → 1¹ + 3² + 5³ = 1 + 9 + 125 = 135
  • 89 → 8¹ + 9² = 8 + 81 = 89
  • 175 → 1¹ + 7² + 5³ = 1 + 49 + 125 = 175

Therefore, numbers like 89, 135, 175 are Disarium Numbers.

How Do We Check Disarium Numbers in Java?

The steps are:

  1. Count the digits of the number
  2. Extract digits one by one
  3. Raise each digit to the power of its position
  4. Sum the powered digits
  5. Compare the sum with the original number

Java Program to Check Disarium Number


import java.util.*;

public class DisariumNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int num = sc.nextInt();

        int temp = num;
        int digits = Integer.toString(num).length();
        int sum = 0;

        while (temp > 0) {
            int digit = temp % 10;
            sum += Math.pow(digit, digits);
            digits--;
            temp /= 10;
        }

        if (sum == num) {
            System.out.println(num + " is a Disarium Number.");
        } else {
            System.out.println(num + " is NOT a Disarium Number.");
        }
    }
}

  

Example Walkthrough

Consider the number 135:

  • Digits = 1, 3, 5
  • Positions = 1, 2, 3
  • Calculation = 1¹ + 3² + 5³ = 135

Since the sum matches the number, 135 is a Disarium Number.

List of Known Disarium Numbers

  • 1
  • 2
  • 3
  • 89
  • 135
  • 175
  • 518
  • 598

Practice Challenge

Write a Java program to print all Disarium Numbers between 1 and 500. Apply the same logic inside a loop and display only the numbers that satisfy the Disarium condition.

You might also like

Fascinating Number in Java with Explanation, Definition, Examples, and Program

A Fascinating Number is a number which, when multiplied by 2 and 3 and then concatenated with itself, forms a string that contains all digits from 1 to 9 exactly once.

Check Perfect Square in Java Without Using Math.sqrt() – Explanation, Logic, Examples, and Program

Learn how to check whether a number is a Perfect Square in Java without using Math.sqrt(). This guide explains the logic, provides examples, and includes an efficient program using iterative checking.

Spy Number in Java — Definition, Logic, Examples, and Program

Learn what a Spy Number is in Java with clear explanations and examples. This blog covers the definition, logic, step-by-step approach, and a clean Java program to check whether a number is a Spy Number. Includes practice challenges to improve your number theory skills.

Automorphic Number in Java: Definition, Explanation, and Step-by-Step Program

A clear and detailed guide on Automorphic Numbers in Java, including definition, examples, logic breakdown, and a complete Java program. Ideal for beginners, students, and coding interview preparation.

Happy Number in Java

Learn what a Happy Number is and how to check whether a number is happy or not in Java. This guide explains the concept, algorithm, working process, dry run, and provides multiple Java programs for beginners.

Sad Number in Java — Definition, Explanation, Examples, and Program

Learn what a Sad Number is in Java with clear explanation and logic. This blog covers the definition of a Sad Number, how it differs from a Happy Number, examples, and a complete Java program. Includes practice challenges to strengthen your number theory concepts.