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 ; calculate log2 N indirectly using log ( ) method ; Driver Code
using System ; class GFG { static int smallestNum ( int n ) { double power = log2 ( 10 ) ; return ( int ) Math . Ceiling ( ( n - 1 ) * power ) ; } static double log2 ( int N ) { return ( Math . Log ( N ) / Math . Log ( 2 ) ) ; } public static void Main ( ) { int n = 4 ; Console . Write ( smallestNum ( n ) ) ; } }