Count positive integers with 0 as a digit and maximum ' d ' digits | Java program to find the count of natural numbers upto a given number of digits that contain atleast one zero ; Utility 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
import java . io . * ; import java . math . * ; class GFG { static int findCountUpto ( int d ) { int GP1_Sum = 9 * ( ( int ) ( ( Math . pow ( 10 , d ) ) - 1 ) / 9 ) ; int GP2_Sum = 9 * ( ( int ) ( ( Math . pow ( 9 , d ) ) - 1 ) / 8 ) ; return GP1_Sum - GP2_Sum ; } public static void main ( String args [ ] ) { int d = 1 ; System . out . println ( findCountUpto ( d ) ) ; d = 2 ; System . out . println ( findCountUpto ( d ) ) ; d = 4 ; System . out . println ( findCountUpto ( d ) ) ; } }