Count N | JavaScript program for the above approache ; Function to find the value of x ^ y ; Stores the value of x ^ y ; Iterate until y is positive ; If y is odd ; Divide y by 2 ; Return the value of x ^ y ; Function to find the number of N - digit integers satisfying the given criteria ; Count of even positions ; Count of odd positions ; Return the resultant count ; Driver Code
var m = 10 ** 9 + 7 function power ( x , y ) { var res = 1 while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % m y = y >> 1 x = ( x * x ) % m } return res } function countNDigitNumber ( N ) { var ne = Math . floor ( N / 2 ) + N % 2 var no = Math . floor ( N / 2 ) return power ( 4 , ne ) * power ( 5 , no ) } let N = 5 document . write ( countNDigitNumber ( N ) % m ) ;