human
Write me a code to check if N is divisible by a number which is composed of the digits from the set { A , B } and the other steps required given the following:
Check if N is divisible by a number which is composed of the digits from the set { A , B } | Function to check whether n is divisible by a number whose digits are either a or b.
base condition.
recursive call.
Check for all numbers beginning with ' a ' or 'b.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if N is divisible by a number which is composed of the digits from the set { A , B } and the other steps required.
 def isDivisibleRec ( x , a , b , n ) :
	if ( x > n ) :
		return False
	if ( n % x == 0 ) :
		return True
	return ( isDivisibleRec ( x * 10 + a , a , b , n ) or isDivisibleRec ( x * 10 + b , a , b , n ) )
def isDivisible ( a , b , n ) :
'
	return ( isDivisibleRec ( a , a , b , n ) or isDivisibleRec ( b , a , b , n ) )
a = 3 ; b = 5 ; n = 53 ;
if ( isDivisible ( a , b , n ) ) :
	print ( " Yes " )
else :
	print ( " No " )