Question: Python The recursive function check(n1,n2) gets 2 positive integer numbers n1, n2. n1>0, n2>0. The function return True if the sum of all odd digits

 Python The recursive function check(n1,n2) gets 2 positive integer numbers n1,n2. n1>0, n2>0. The function return True if the sum of allodd digits in n1 is equal to the sum of all odddigits in n2. Otherwise it returns False. (Reminder - odd means -

Python The recursive function check(n1,n2) gets 2 positive integer numbers n1, n2. n1>0, n2>0. The function return True if the sum of all odd digits in n1 is equal to the sum of all odd digits in n2. Otherwise it returns False. (Reminder - odd means - can NOT divide by 2). Examples: check(248,884241) == False No odd digits in 248 therefore the sum of odd digits in this case is 0. Odd digits in 884241 is only one digit - 1. The sum of all odd digits is 1. We get 0 != 1, therefore answer is False. check(32485,7006601) == True odd digits in 32485 are 3,5 odd digits in 7006601 are 7, 1 (notice that we treat 0 as an even digit) We get 3+5==7+1, therefore answer is True As we can see from the above examples, if a number does not have odd digits then the sum of the odd digits is 0. Complete the partial code given for the function check. def check(n1,n2): if n1==n2==0: elif n1==0: elif n2==0: else: Requirements : 1. The function MUST be recursive. Must NOT write any other function in addition to check. Must NOT change parameters of check. 2. Must NOT use loops. 3. Must NOT use lists nor strings nor other types. Only int is allowed. Hint: check the right most digits if they are even or odd, as we've done in class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!