Question

def ged(m,n) : if m n == 0: return n else: return god (n, møn) Without typing the code into Python, what are the values of th
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer is m = 9 and n = 8.

Explanation:

When the first call is made from main function, the input arguments will be m=537 and n=44.

In the function gcd, if condition is not true so it goes to else block. This is the first recursive call to the function. The input arguments will be m=44 and n=9.

After the first recursive call also the if condition will not be true so it goes to else block. This is the second recursive call to the function. The input arguments will be m=9 and n=8.

Add a comment
Know the answer?
Add Answer to:
def ged(m,n) : if m n == 0: return n else: return god (n, møn) Without...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Programming assignment : Function of Q3: def isPositive(n): if(n>=0): return True else: return False Write...

    Python Programming assignment : Function of Q3: def isPositive(n): if(n>=0): return True else: return False Write a code for function main, that does the following: -creates a variable and assigns it the value True. - uses a while loop which runs as long as the variable of the previous step is True, to get a number from the user and if passing that number to the function of Q3 results in a True value returned, then add that number to...

  • Python Programming assignment : Function of Q3: def isPositive(n): if(n>=0): return True else: return False Write...

    Python Programming assignment : Function of Q3: def isPositive(n): if(n>=0): return True else: return False Write a code for function main, that does the following: -creates a variable and assigns it the value True. - uses a while loop which runs as long as the variable of the previous step is True, to get a number from the user and if passing that number to the function of Q3 results in a True value returned, then add that number to...

  • Consider the following code for a Fraction class: self. numerator = 0 self tsn return self. denominator # Greatest Common Divisor def GCD (self, m, n): while n != 0: m=t return m def reduce(self...

    Consider the following code for a Fraction class: self. numerator = 0 self tsn return self. denominator # Greatest Common Divisor def GCD (self, m, n): while n != 0: m=t return m def reduce(self): gcd - self.GCD(self._numerator, self._denominator) self. numerator int(self,_numerator / gcd) self'-denominator înt (self-denominator, gcd) def_str (self): 프 str(self-numerator). "ItDenominator, return "Numerator : str(self,-deno 프, . minator) Write a Unittest framework class to test the GCD method presented in the Fraction class Upload your answer code to...

  • ###############recursion (Python) ##def facto( num ): ## if num == 0: ## return 1 ## else:...

    ###############recursion (Python) ##def facto( num ): ## if num == 0: ## return 1 ## else: ## return num * facto( num - 1 ) ## ##Task 2. N! = 1*2*3*...*(N-1)*N as we know. There is another "double factorial": ##N!! : ##1)if N is odd then N!! = 1*3*5*7*9*...*N ##2)if N is even then N!! = 2*4*6*8*...*N ## ####Task 2. Create a function facto2 which calculates facto2(N) = N!! ##Show that your function works. ######use input(...)

  • Programming Exercise 11.6 Х + | Instructions fib.py >_ Terminal + iit B 1 def fib(n):...

    Programming Exercise 11.6 Х + | Instructions fib.py >_ Terminal + iit B 1 def fib(n): 2 "*"Returns the nth Fibonacci number. " 3 if n < 3: lil 4 return 1 Modify the recursive Fibonacci function to employ the memoization technique discussed in this chapter. The function creates a dictionary and then defines a nested recursive helper function named memoizedFib You will need to create a dictionary to cache the sum of the fib function. The base case of...

  • #include <stdio.h>    int josephus(int n, int k) {   if (n == 1)     return 1;   else...

    #include <stdio.h>    int josephus(int n, int k) {   if (n == 1)     return 1;   else     /* The position returned by josephus(n - 1, k) is adjusted because the        recursive call josephus(n - 1, k) considers the original position         k%n + 1 as position 1 */     return (josephus(n - 1, k) + k-1) % n + 1; }    // Driver Program to test above function int main() {   int n = 14;   int k = 2;   printf("The chosen place...

  • 1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write...

    1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write a Python program that prompts the user for a sentence, then replaces all the vowels in the sentence with an asterisk: '*' Your program should use/call your isVowel function from Assignment_Ch06-01. You can put the isVowel() function in a separate .py file, without the rest of the Ch06-01 code, and then import it. 6-01 CODE: def isVowel(x):     if x in "aeiouyAEIOUY":         return True     else:...

  • Question 18 CLO3 Analyze the following code and answer the questions that follow def F(n): If n <= 1: return n else: return F(n-1)+F(n-2) for i in range (n) print (F(i)) Result: 0 1 1 2 3 5 8...

    Question 18 CLO3 Analyze the following code and answer the questions that follow def F(n): If n <= 1: return n else: return F(n-1)+F(n-2) for i in range (n) print (F(i)) Result: 0 1 1 2 3 5 8 13 a. Write number of operations as a function when the code is execute b If n 7, what is the total number of operations? c. What is the complexity of the algorithm behind the code? (2 Marks) (2 Marks) (1...

  • Please help and show explicitly the solutions - and explanation too ! Read the code for...

    Please help and show explicitly the solutions - and explanation too ! Read the code for the recursive function count_odd, which operates on a nested list. def count odd (obj: Union int, List]) -> int: Return the number of odd numbers in <obj if isinatance (obj, int): íf obj % 2-0: return else: return 1 else: for sublist in obj: return count_odd (sublist) Answer the questions below about the following call to count.odd. >>>count odd([1, [2, 6, 5], [9, [8,...

  • C++ PROGRAM ONLY! For this lab you need to write a program that will read in...

    C++ PROGRAM ONLY! For this lab you need to write a program that will read in two values from a user and output the greatest common divisor (using a recursive implementation of the Euclidean algorithm) to a file. In Lab #3, you implemented this program using an iterative method. Greatest Common Divisor In mathematics, the greatest common divisor (GCD) of two or more integers (when at least one of of them is zero then the larger value is the GCD....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT