human
Count of N | Function to return the count of n - digit numbers that satisfy the given conditions.
DP array to store the pre - caluclated states.
Base cases.
i - digit numbers ending with 0 can be formed by concatenating 0 in the end of all the ( i - 1 ) - digit number ending at a non - zero digit.
i - digit numbers ending with non - zero can be formed by concatenating any non - zero digit in the end of all the ( i - 1 ) - digit number ending with any digit.
n - digit number ending with and ending with non - zero.
Driver code"
Solution in Python:
assistant
#Here is code to count of N and the other steps required.
 def count_numbers ( k , n ) :
	dp = [ [ 0 for i in range ( 2 ) ] for i in range ( n + 1 ) ]
	dp [ 1 ] [ 0 ] = 0
	dp [ 1 ] [ 1 ] = k - 1
	for i in range ( 2 , n + 1 ) :
		dp [ i ] [ 0 ] = dp [ i - 1 ] [ 1 ]
		dp [ i ] [ 1 ] = ( dp [ i - 1 ] [ 0 ] + dp [ i - 1 ] [ 1 ] ) * ( k - 1 )
	return dp [ n ] [ 0 ] + dp [ n ] [ 1 ]
k = 10
n = 3
print ( count_numbers ( k , n ) )