Count positive integers with 0 as a digit and maximum ' d ' digits | function to calculate the count of natural numbers upto a given number of digits that contain atleast one zero ; Sum of two GP series ; Driver Code
function findCountUpto ( d ) { let GP1_Sum = 9 * ( ( Math . pow ( 10 , d ) - 1 ) / 9 ) ; let GP2_Sum = 9 * ( ( Math . pow ( 9 , d ) - 1 ) / 8 ) ; return GP1_Sum - GP2_Sum ; } let d = 1 ; document . write ( findCountUpto ( d ) + " " ) ; d = 2 ; document . write ( findCountUpto ( d ) + " " ) ; d = 4 ; document . write ( findCountUpto ( d ) + " " ) ;