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
A DTP setup includes many hardware and software components.
QveST [7]

Answer:

Apple Laser Writer is an example of a DTP <u>Hardware.</u>

Explanation:

DTP means Desktop Publishing. It may include the hardware and software. The DTP hardware includes two major parts a computer and a printer. The DTP software includes the software such as Photoshop, illustrator an other software that needs in desktop publishing.

Apple laser writer is a printer that is used to print the text and diagrams that we make using DTP software tools.

7 0
3 years ago
Should spreadsheets be used to capture the results of a science experiment?<br><br> YES<br> NO
Lyrx [107]

Answer:

Yes

Explanation:

Spreadsheets should be used to capture the results of science experiments because they are good for sorting data. They make results easier and information easier to see and use.

3 0
2 years ago
Read 2 more answers
True or false? (a) Main memory is volatile. (b) Main memory is accessed sequentially. (c) Disk memory is volatile. (d) Disk memo
allochka39001 [22]

Answer:

The answer to your question is true

5 0
3 years ago
How do you take a picture on an apple computers
Mamont248 [21]

Answer:

You go to the launcher, then find Photo Booth. Photo Booth allows you to take photos. You can only take photos on the side where the screen is, since there isn't a camera on the back. I recommend taking a picture with a phone instead. For a screenshot, press command-shift-3.

Hope this helps!

3 0
3 years ago
HELPPPPPPPPP MEEEEE :):):):):)
Pepsi [2]
I believe it’s b. Link text
7 0
3 years ago
Other questions:
  • Universal Containers recently rolled out a Lightning Knowledge implementation; however, users are finding unreliable and unrelat
    6·1 answer
  • What is the quick key to highlighting a column?
    14·1 answer
  • The device that links computers via communication lines is called the:
    15·1 answer
  • Write the half function. A function call and the functionprototype
    12·1 answer
  • Which format is best for the image below?
    12·1 answer
  • What command would you use to copy the content of a file named report1 to another called report1uc. Convert the content of repor
    12·1 answer
  • How many cost units are spent in the entire process of performing 40 consecutive append operations on an empty array which start
    14·1 answer
  • When you start a new blank document, you begin typing at the
    6·1 answer
  • HELPPPPPPPP
    12·2 answers
  • A column does not consist of
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!