Number of digits in 2 raised to power n | Java program to find number of digits in 2 ^ n ; Function to find number of digits in 2 ^ n ; Driver Code
import java . util . * ; class Gfg { static int countDigits ( int n ) { return ( int ) ( n * Math . log10 ( 2 ) + 1 ) ; } public static void main ( String args [ ] ) { int n = 5 ; System . out . println ( countDigits ( n ) ) ; } }