We value your feedback.

Take our survey and automatically be enter to win anyone of the following:

Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

But let's see if we can do it anyway:

First let's see if we can generate powers of a number. If we can do that much, then we just need to call this power macro until we get a match. A bit slow but you didnt specify what speed you wanted!

We have to use recursion, so it's going to be something like:

#define Power(x,y) ( Power( x, (y - 1) ) * (x) )

... but we need it to stop expanding at y = 0, so we need some text_fudging for that special case:

#define Power_0 1

#define Power_1(x,y) Power_##y(x,y) // define about 100 of these up til Power_100

Don't have a c compiler handy right here so you'll have to trust me on this one.

... then to do an equality test, that's even harder as cpp doesnt have any Arithmetic IFs, but you can fake it with multiplication and subtraction and recursion:

#define FindIfPerfectSquare(y,x) ( y * ((y) - FindIfPerfectSquare( y, x - 1 ))))

Done just right this will expand to a long expression: (yournumber - power(99, 2 ) * ( yournumber - Power( 98,2 )

... IT STILL NEEDS SOME WORK, but I *think* the general idea is in there...