human
Give me a code to add N digits to A such that it is divisible by B after each addition and the other steps required given the following:
Add N digits to A such that it is divisible by B after each addition | Python3 implementation of the approach.
Try all digits from ( 0 to 9 ).
Fails in the first move itself.
Add ( n - 1 ) 0 's.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to add N digits to A such that it is divisible by B after each addition and the other steps required.
 def addNDigits ( a , b , n ) :
	num = a
	for i in range ( 10 ) :
		tmp = a * 10 + i
		if ( tmp % b == 0 ) :
			a = tmp
			break
	if ( num == a ) :
		return - 1
	for j in range ( n - 1 ) :
		a *= 10
	return a
if __name__ == " _ _ main _ _ " :
	a = 5
	b = 3
	n = 3
	print ( addNDigits ( a , b , n ) )