Hi, I found an exercise on my book like this:
"Exist 4 numbers, smallers than 500, that are special. If we take all his chars, but one after one, and elevates to the 3rd power, this will return the number. example:
1^3 + 5^3 + 3^3 = 153"
Now I need to make a program, to discover all numbers like this btw 0 and 500.
I dont know where to start, cuz the only way I found is making just on Loop, and than convert the number(index) into string, catch all the 3 chars of the string, that represents a single number and then transform then into Integer, apply the 3rd power on them, sum and than see if it is equals to the NUM.
But I think have another way, not? my way is so stupid I think.
I dont need you guys make my home-work, I just want to understand.
Thanks!!!



LinkBack URL
About LinkBacks




0^3 + 0^3 + 0^3 is 0