Number of digits in 2 raised to power n | CPP program to find number of digits in 2 ^ n ; Function to find number of digits in 2 ^ n ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countDigits ( int n ) { return ( n * log10 ( 2 ) + 1 ) ; } int main ( ) { int n = 5 ; cout << countDigits ( n ) << endl ; return 0 ; }