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
to verify that the ip address sorting criteria that has not been configured to overlap between different groups you can use the
blsea [12.9K]

For one to be able to verify that the ip address sorting criteria that has not been configured to overlap between different groups you can use the check IP group - testing.

<h3>What does IP group do?</h3>

The term IP Group is known to be one that looks at or is one whose purpose is so that it can  generate  a lot of a positive social and also that of environmental impact with financial returns.

Note that this is one that offers shareholders a kind of an exposure to a a lot of portfolio of opportunities that is made up of a  high-growth businesses in regards to the growth markets.

Hence, For one to be able to verify that the ip address sorting criteria that has not been configured to overlap between different groups you can use the check IP group - testing.

Learn more about IP address from

brainly.com/question/24930846

#SPJ1

7 0
2 years ago
Write equivalent predicate statement for Every teacher who is also a painter loves Bob​
Pie

Answer:

Every teacher who is also a painter loves Bob

7 0
3 years ago
Read 2 more answers
1) Moore's law refers to:
liraira [26]

Answer:

Moore's Law refers to the. number of transistors inside a CPU chip. When the CPU actually performs the work described in the commands during a machine cycle, this stage is known as. Execute.

Explanation:

4 0
3 years ago
What is system software?<br><br> No Spam<br><br> Answer quickly
LenKa [72]

\large{\underline{\underline{\pmb{\tt{Answer:}}}}}

  • <u>System software</u> controls a computer's internal functioning, chiefly through an operating system, and also controls such peripherals as monitors, printers, and storage devices.
4 0
3 years ago
Read 2 more answers
Which one bc im struggling
Setler79 [48]

Answer:

cant really see it

Explanation:

3 0
3 years ago
Other questions:
  • What are the verison of ip user nearly limitless ip address?
    14·1 answer
  • Which operating system is a version of Linux?​
    13·1 answer
  • Anyone here play sims 4 and know how to help me with his last exception file?
    15·1 answer
  • Text that appears slightly below the line of the other text in the document is
    5·1 answer
  • While creating a digital portfolio, Harry wants to add documents that authenticate his skills, experience, and knowledge in digi
    11·1 answer
  • Cans someone pls help me to do edhesive 2.5 code practice
    8·1 answer
  • What’s ur guys rank of all 3D Mario games (all of these are great games btw)? These are my opinions I’d rly enjoy hearing yours.
    8·1 answer
  • Whats the overall mood of the song Rags2Riches by rod wave
    14·1 answer
  • What is a survey? plz hel​
    7·2 answers
  • What built-in function should you use in python to prompt a user for data input?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!