Hi everyone. I am new to C++ and I am working on project Euler problem 30 and running into some problems. The problem asks you to find the sum of all the numbers that can be written as the sum of fifth powers of their digits. I think I am on the right track with my code but for some reason it is not returning any numbers. If anyone could take a look at my code and let me know my mistake I would really appreciate it. Thanks for the help!
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
unsignedlong num = 0, tot = 0, final = 0;
int digit = 0;
for(unsignedlong a = 2; a < 4000000; a++)
{
num = a;
while (num)
{
digit = num % 10;
num /= 10;
tot += pow(digit, 5);
}
if (a == tot)
final += a;
}
cout << final << endl;
return 0;
}