Disarium Number in C, C++, Java & Python – Code with Explanation & Examples in Short and Simple

   

C Program

#include <stdio.h>
#include <math.h>

int main() {
    int n, temp, count = 0, sum = 0;
    scanf("%d", &n);
    temp = n;

    // Count digits
    int t = n;
    while (t > 0) {
        count++;
        t /= 10;
    }

    // Calculate sum of digits powered by their positions
    t = n;
    while (t > 0) {
        int digit = t % 10;
        sum += pow(digit, count);
        count--;
        t /= 10;
    }

    if (sum == n) 
        printf("%d is a Disarium Number\n", n);
    else 
        printf("%d is not a Disarium Number\n", n);

    return 0;
}

C Output

Input:
135

Output:
135 is a Disarium Number


C++ Program

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    int temp = n, count = 0, sum = 0;

    // Count digits
    int t = n;
    while (t > 0) {
        count++;
        t /= 10;
    }

    // Sum of powered digits
    t = n;
    while (t > 0) {
        int digit = t % 10;
        sum += pow(digit, count);
        count--;
        t /= 10;
    }

    if (sum == n)
        cout << n << " is a Disarium Number\n";
    else
        cout << n << " is not a Disarium Number\n";
}

C++ Output

Input:
89

Output:
89 is a Disarium Number


JAVA Program

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), temp = n, count = 0, sum = 0;

        // Count digits
        int t = n;
        while (t > 0) {
            count++;
            t /= 10;
        }

        // Sum of powered digits
        t = n;
        while (t > 0) {
            int digit = t % 10;
            sum += Math.pow(digit, count);
            count--;
            t /= 10;
        }

        if (sum == n)
            System.out.println(n + " is a Disarium Number");
        else
            System.out.println(n + " is not a Disarium Number");
    }
}

JAVA Output

Input:
175

Output:
175 is a Disarium Number


Python Program

n = int(input())
num_str = str(n)
length = len(num_str)

sum_val = 0
for i, digit in enumerate(num_str, start=1):
    sum_val += int(digit) ** i

if sum_val == n:
    print(f"{n} is a Disarium Number")
else:
    print(f"{n} is not a Disarium Number")

Python Output

Input:
89

Output:
89 is a Disarium Number


In-Depth Learning – Entire Concept in Paragraphs
Example
A number is referred to as a Disarium Number if the sum of its digits raised to the respective positions is equal to the number itself. For example, consider 135:
1¹ + 3² + 5³ = 1 + 9 + 125 = 135. Therefore, 135 is a Disarium Number. Likewise, 89 is a Disarium Number because 8¹ + 9² = 8 + 81 = 89.

Real-Life Analogy
Consider a Disarium Number as a student's report card in which every subject score gets multiplied by its weighting. If the weighted score is identical to the student's roll number, it forms a perfect identity. Similarly here, in Disarium Numbers, every digit "knows its place" and contributes as per its place power.

Why It Matters
This thing introduces us to the idea of positional significance in mathematics and computer programming. Under normal circumstances, numbers are merely thought of as integers, but here position is significant, like role importance in a team. Without adequate positioning, the outcome would never be the same.

Learning Insights
This problem teaches you digit manipulation, iterating through numbers, position tracking, and power calculations. It also enhances understanding of how digits and positions can be creatively employed to solve mathematical puzzles. Newcomers learn how to dissect numbers digit by digit and apply conditions incrementally.

Interview Use Case
In interviews, these issues try your skills in dealing with number theory, loops, and logic building. It demonstrates if you possess algorithmic thinking where you can break numbers apart and recombine them using mathematical principles. Disarium Numbers belong to the same group of fascinating problems as Armstrong, Automorphic, and Harshad Numbers that are usually requested by recruiters.

Real-World Applications
While Disarium Numbers are generally mathematical curiosities, the principle is employed in digital validation, checksum verification, and even in cryptography, where numbers have to be assembled based on their positions and weights in order to generate unique identities. 

SEO-Optimized Conclusion
A Disarium Number is an interesting mathematical phenomenon in which digits to the positional powers sum to the number itself. Learning to program Disarium Number applications in C, C++, Java, and Python enables beginners to learn loops, digit extraction, and logical math concepts step-by-step. The applications are commonly practiced during coding interviews and programming competitions since they hone number manipulation skills and logical thinking. If you are studying for coding tests, competitive programming, or employment interviews, Disarium Numbers will provide you with a solid base in number theory problems along with boosting your confidence in problem-solving using C, C++, Java, and Python.