Ian Dorian Macleod
Problem 30
Problem Statement

Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:

1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44

As 1 = 14 is not a sum it is not included.

The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

url: https://projecteuler.net/problem=30
Approach

C++ implementation

#include <iostream>
#include <math.h>

using namespace std;

bool check(int n) {
    int sum = 0;
    int tmp = n;
    while (tmp > 0) {
        sum += pow((tmp % 10), 5);
        tmp /= 10;
    }
    return (sum == n) ? true : false;
}

int main() {
    long long int sum = 0;
    for(int i = 2; i < 1000000; i++) {
        if (check(i)) sum += i;
    }
    cout << "hi" << endl;
    cout << sum << endl;
    return 0;
}

You can also download the source code for this problem here and compile it on your local machine.
Further Analysis