Smallest power of 2 consisting of N digits | C ++ Program of the above approach ; Function to return smallest power of 2 consisting of N digits ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int smallestNum ( int n ) { float power = log2 ( 10 ) ; cout << power ; return ceil ( ( n - 1 ) * power ) ; } int main ( ) { int n = 4 ; cout << smallestNum ( n ) ; return 0 ; }