Find a three digit number that fits the following criteria:
1)The digits are all different.
2)When each digit is squared and added together the number is the same as the number formed by the 2nd and 3rd digits in the number.
3)When the number formed by the last two digits is squared then added to (the first digit squared and added to itself) it is the same as the original number.
How many different three digit numbers are there that fit the criteria?
I found only
420
with the following program:
#include <iostream.h>
int main(int argc, char* argv[])
{
int a, b, c;
for (a=1; a<10; a++)
{
for (b=0; b<10; b++)
{
for (c=0; c<10; c++)
{
if ( (a!=b) && (a!=c) && (b!=c) )
{
if ( ((a*a) + (b*b) + (c*c)) == (10*b + c) )
{
if ( ( ((10*b+c)*(10*b+c)) + (a*a + a)) == (100*a + 10*b + c) )
cout << a << b << c << endl;
}
}
}
}
}
return 0;
}