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
< ? php function findCountUpto ( $ d ) { $ GP1_Sum = 9 * ( ( pow ( 10 , $ d ) - 1 ) / 9 ) ; $ GP2_Sum = 9 * ( ( pow ( 9 , $ d ) - 1 ) / 8 ) ; return $ GP1_Sum - $ GP2_Sum ; } $ d = 1 ; echo findCountUpto ( $ d ) , " STRNEWLINE " ; $ d = 2 ; echo findCountUpto ( $ d ) , " STRNEWLINE " ; $ d = 4 ; echo findCountUpto ( $ d ) , " STRNEWLINE " ; ? >