Skip to content

Instantly share code, notes, and snippets.

@azyu
Created May 17, 2015 14:32
Show Gist options
  • Save azyu/eeb868e37087ce6df991 to your computer and use it in GitHub Desktop.
Save azyu/eeb868e37087ce6df991 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int total = 0;
char buf[256];
string s;
for(int i = 2; i < 999999 ; ++i)
{
_itoa(i, buf, 10);
s = buf;
int sum = 0;
for each(char c in s)
{
sum += pow(atof(&c), 5);
}
if( i == sum )
{
for each(char c in s)
{
cout << c << "(" << pow(atof(&c), 5) << ") ";
}
cout << endl;
total += sum;
cout << "Sum: " << sum << " Total: " << total << endl;
}
}
cout << total << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment