Find the total count of numbers up to N digits in a given base B | C # implementation to find the count of natural numbers upto N digits ; Function to return the count of natural numbers upto N digits ; Loop to iterate from 1 to N and calculating number of natural numbers for every ' i ' th digit . ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static int count ( int N , int B ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += ( int ) ( ( B - 1 ) * Math . Pow ( B , i - 1 ) ) ; } return sum ; } public static void Main ( String [ ] args ) { int N = 2 , B = 10 ; Console . Write ( count ( N , B ) ) ; } }