Just out of curiosity, how can you tell if a number x is a power of two (x = 2^n) without using recursion.
Thanks
If it's a power of 2? Well, one way is to convert it to binary, and verify the presence of only 1 1...:
1
$bin = decbin($number); if (preg_match('/^0*10*$/', $bin)) { //Even Power Of 2 }