Check if a number can be expressed as a ^ b | Set 2 | PHP program to check if a number can be expressed as a ^ b . ; Driver code
< ? php function isPower ( $ a ) { if ( $ a == 1 ) return true ; for ( $ i = 2 ; $ i * $ i <= $ a ; $ i ++ ) { $ val = log ( $ a ) / log ( $ i ) ; if ( ( $ val - $ val ) < 0.00000001 ) return true ; } return false ; } $ n = 16 ; echo ( isPower ( $ n ) ? " Yes " : " No " ) ;