text: Program to find whether a no is power of two | PHP Program to find whether a no is power of two Function to check Log base 2 ; Function to check if x is power of 2 ; Driver Code
code: < ? php function Log2 ( $ x ) { return ( log10 ( $ x ) / log10 ( 2 ) ) ; } function isPowerOfTwo ( $ n ) { return ( ceil ( Log2 ( $ n ) ) == floor ( Log2 ( $ n ) ) ) ; } if ( isPowerOfTwo ( 31 ) ) echo " Yes STRNEWLINE " ; else echo " No STRNEWLINE " ; if ( isPowerOfTwo ( 64 ) ) echo " Yes STRNEWLINE " ; else echo " No STRNEWLINE " ; ? >