Dudeney number in Java
**Cracking the Enigma of Dudeney Numbers in Java**
In the realm of number theory, there are hidden treasures waiting to be uncovered.One such treasure is the Dudeney number, named after the British mathematician Henry Dudeney. These numbers possess a fascinating property that combines arithmetic and algebra. In this article, we will embark on a journey to understand Dudeney numbers and create a Java program to check whether a given number is one of these enigmatic integers.
**What Is a Dudeney Number?**
A Dudeney number is a positive integer that can be expressed as the sum of its own digits, each raised to the power of its own value. Mathematically, if 'n' is a Dudeney number, it satisfies the following equation:
n = (d1^1)+(d2^2)+(d3^3)+ .. + (dn^ n)
Where d1, d2,d3,..., dn are the individual digits of 'n.'
For example, let's take the number 89:
- 8^1 + 9^2 = 8 + 81 = 89
Since 89 can be expressed as the sum of its digits raised to their respective powers, it qualifies as a Dudeney number.
**Coding the Dudeney Number Checker in Java**
Source code of Program
import java.util.Scanner;
class dudney
{
public static void main(String Ar[])
{
Scanner obj=new Scanner(System.in);
System.out.println("enter a number");
int num=obj.nextInt();
int n=num,r,s=0,cu;
while(n!=0)
{
r=n%10;
s=s+r;
n/=10;
}
cu=s*s*s;
if(cu==num)
System.out.println("dudney number");
else
System.out.println("not dudney number");
}
}
Now that we understand the concept, let's create a Java program that checks whether a given number is a Dudeney number or not.
In this Java program, we first take input from the user and then use the `is Dudeney Number` function to determine if the input number is a Dudeney number.
**Running the Dudeney Number Checker**
Compile and run the Java program, and you can start testing various numbers to discover whether they are Dudeney numbers or not. The program will inform you of the result.
**Conclusion**
Dudeney numbers are an intriguing mathematical phenomenon, and with our Java program, you can easily identify these unique integers. By using the power of Java programming, you can unlock the secrets of Dudeney numbers and add another tool to your mathematical toolkit.
Feel free to modify or expand upon this program as needed. Happy number hunting!
---
I hope you find this article helpful for understanding and identifying Dudeney numbers in Java. If you have any fur
ther questions or requests, please let me know!
![]() |
| Output Screen |

0 Comments