Number of digits in 2 raised to power n | Function to find number of digits in 2 ^ n ; Driver code
< ? php function countDigits ( $ n ) { return intval ( $ n * log10 ( 2 ) + 1 ) ; } $ n = 5 ; echo ( countDigits ( $ n ) ) ; ? >