Dudeney Number Demystified (With Simple Java Code)- For Beginners
INTRODUCTION
A Dudeney number is a positive integer for which the sum of its digits is equal to the the cube root of the number itself. The name derives from Henry Dudeney, who noted the existence of these numbers in one of his puzzles, Root Extraction, where a professor in retirement at Colney Hatch postulated this as a general method for root extraction.
For example:
For in-depth Mathematical information regarding the nature of the Dudeney Number -
JAVA CODE
public class Dudeney
{
public static void main(int n)
{
int x = n; //Creating a copy of the number
int sum = 0; //Variable to calculate sum of digits
while(n != 0)
{
int a = n % 10; //Extracting the Digit
sum = sum + a; //Calculating the sum of Digits
n = n/10; //Reducing the number of Digit by 1 (removing the units Digit)
}
if(x == (sum * sum * sum)) //Condition for a Dudeney Number
System.out.println("Yes; A Dudeney Number");
else
System.out.println("Not a Dudeney Number");
}
}
LIST OF DUDENEY NUMBERS
- 0
- 1
- 512
- 4913
- 5832
- 17576
- 19683
If interested in knowing the proof of the statement by using techniques like Bounding From Above, Limiting The Search Space, and Brute Forcing The Remaining Possibilities ⬇️
If you would like to read more blogs written by me, SIGN UP here ⬇️ 📩