1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dem82 [27]
3 years ago
8

For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a recursive function. Write a recursive method g

cd(m,n) to find their Greatest Common Divisor. Once m is 0, the function returns n. Once n is 0, the function returns m. If neither is 0, the function can recursively calculate the Greatest Common Divisor with two smaller parameters: One is n, the second one is m mod n. Although there are other approaches to calculate Greatest Common Divisor, your program should follow the instructions of this question, otherwise you will not get the credit. Then write a testing program to call the recursive method.
Computers and Technology
1 answer:
konstantin123 [22]3 years ago
6 0

Answer:

In Python:

def gcd(m,n):

if n == 0:

 return m

elif m == 0:

    return n

else:

 return gcd(n,m%n)

Explanation:

This defines the function

def gcd(m,n):

If n is 0, return m

<em> if n == 0: </em>

<em>  return m </em>

If m is 0, return n

<em> elif m == 0: </em>

<em>     return n </em>

If otherwise, calculate the gcd recursively

<em> else: </em>

<em>  return gcd(n,m%n)</em>

<em />

<em>To call the function to calculate the gcd of say 15 and 5 from main, use:</em>

<em>gcd(15,5)</em>

You might be interested in
In CadStd, what does the Zoom All button do? A. Makes a drawing bigger so you can see small details B. Returns a drawing to a si
Afina-wow [57]
I belive in CadStd that the zoom all button <span>makes a drawing bigger so you can see small details</span>
3 0
3 years ago
Full form of http.<br>wrong answer will be reported ​
vodomira [7]

Answer:

So it is Hyper Text Transfer Protocol.

Hope it helps

6 0
3 years ago
Read 2 more answers
QUESTION: Which is not an example of a video port or cable?
Vikki [24]

Answer:

Radio Corporation of America (RCA)

Explanation:

A corporation is not a video connector.

8 0
3 years ago
One of your start-ups uses error-correcting codes, which can recover the original message as long as at least 1000 packets are r
Marina CMI [18]

Answer:

Number of packets ≈ 5339

Explanation:

let

X = no of packets that is not erased.

P ( each packet getting erased ) = 0.8

P ( each packet not getting erased ) = 0.2

P ( X ≥ 1000 ) = 0.99

E(x) = n * 0.2

var ( x ) = n * 0.2 * 0.8

∴ Z = X - ( n * 0.2 ) / \sqrt{n*0.2*0.8}   ~ N ( 0.1 )

attached below is the remaining part of the solution

note : For the value of <em>n</em> take the positive number

5 0
3 years ago
An algorithm requires numbers.<br> O True<br> O<br> False
Naya [18.7K]
True hope this helps
6 0
3 years ago
Read 2 more answers
Other questions:
  • A company is a Microsoft 365 reseller. The company does not provide managed services or direct customer support. You need to pro
    10·1 answer
  • An email address is made up of all of the following parts except
    13·2 answers
  • I need the code for Assignment 5 Animation in Edhesive, its in python code.
    9·1 answer
  • What are five most important areas of the animal industry that involve science and technology?
    14·1 answer
  • 7. The penalties for a first-time DUI charge include a fine of __________. A. up to $500 for a BAL of .08 to .15 B. $500-$1,000
    5·1 answer
  • Write a C++ program to find if a given array of integers is sorted in a descending order. The program should print "SORTED" if t
    14·1 answer
  • How does the post process alert the user if it detects a hardware problem during the post process?
    6·1 answer
  • A Cisco Catalyst switch has been added to support the use of multiple VLANs as part of an enterprise network. The network techni
    5·1 answer
  • Can a idler gear increase or decrease torque?
    7·1 answer
  • Make The PYTHON Code<br><br> print first 3 character of a string - given "Seattle" expected "Sea"
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!