Smallest power of 2 consisting of N digits | C # program to implement the above approach ; Function to return smallest power of 2 with N digits ; Iterate through all powers of 2 ; Driver Code
using System ; class GFG { static int smallestNum ( int n ) { for ( int i = 2 ; ; i *= 2 ) { int length = ( int ) ( Math . Log10 ( i ) ) + 1 ; if ( length == n ) return ( int ) ( Math . Log ( i ) / Math . Log ( 2 ) ) ; } } public static void Main ( ) { int n = 4 ; Console . Write ( smallestNum ( n ) ) ; } }