# Calculate numbers that are equal to the sum of the fifth powers of their digits

// Calculate numbers that are equal to the sum of their digits to the 5th power.

// This will run for a very long time as written. // An upper bound would be useful, but deciding on that value is problematic.

public static long Solve() { long result = 0; long num = 2, tmp, sum; int digit; try { while (num > 0) { tmp = num; sum = 0; while (tmp != 0) { digit = (int) tmp % 10; sum = sum + digit * digit * digit * digit * digit; tmp /= 10; } if (sum == num) { System.out.println("Number found: " + sum); result += sum; } num++; } } catch (Exception ex) { System.out.println("Solve(): " + ex.getMessage()); } return result; }

## More by this Author

- 25
Churning round and round in the basement, the washing machine usually spends its' useful life as an unappreciated member of the appliance family...

- 86
Ever been to a NASCAR race? I thought not. Here are my top 10 reasons why NASCAR racing doesn't rock.

- 12
Data Hiding is an aspect of Object Oriented Programming (OOP) that allows developers to protect private data and hide implementation details. In this tutorial we examine basic data hiding techniques in Java.

## Comments

No comments yet.