# 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

- 5
A useful text editor is an essential component of any personal computer. Every day we need to make notes, compose documents, and record vital pieces of information. We depend on our text editor. Microsoft provided...

- 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.

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

## Comments

No comments yet.