human
Find nth number that contains the digit k or divisible by k . | Function for checking if digit k is in n or not.
finding remainder.
if digit found.
Function for finding nth number.
since k is the first which satisfy th criteria , so consider it in count making count = 1 and starting from i = k + 1.
checking that the number contain k digit or divisible by k.
Driver code"
Solution in Python:
 ... Can you provide a code to find nth number that contains the digit k or divisible by k?
assistant
#Here is code to find nth number that contains the digit k or divisible by k .
 def checkdigit ( n , k ) :
	while ( n ) :
		rem = n % 10
		if ( rem == k ) :
			return 1
		n = n / 10
	return 0
def findNthNumber ( n , k ) :
	i = k + 1
	count = 1
	while ( count < n ) :
		if ( checkdigit ( i , k ) or ( i % k == 0 ) ) :
			count += 1
		if ( count == n ) :
			return i
		i += 1
	return - 1
n = 10
k = 2
print ( findNthNumber ( n , k ) )