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
Using symbols in a file name is a good idea.<br><br> True<br> False
zavuch27 [327]
False. File names should only contain letters, underscores, periods, and dashes.
4 0
3 years ago
Read 2 more answers
1. A device that can be used to insert data into a computer or other computational devices is
Pie

Answer:

Examples of input devices include keyboards, mouse, scanners, digital cameras, joysticks, and microphones.

Explanation:An input device is a piece of computer hardware equipment used to provide data and control signals to an information processing system such as a computer or information appliance.

7 0
3 years ago
Read 2 more answers
The methods of the Character class that begin with ____ return a character that has been converted to the stated format.
Pavel [41]

Answer:

most probably the answer is 'to'

6 0
3 years ago
Which of the following words is an anatomy for cautious
liraira [26]
Uh, I think you mean antonym.

Anyways, here are some antonyms.

Careless, Certain, Foolish, Inattentive, Incautious
8 0
4 years ago
Select the best answer from the drop-down menu.
Orlov [11]

Answer:

1) R<u>easoning</u>

<u>2)Nonverbal</u>

<u>3)Generating solutions.</u>

<u>4)Decision making</u>.

<u>--------------------------------------</u>

Robert is reviewing complex information and data concerning a new product launch to determine the cause of some product failures. He is primarily using <u>reasoning</u> skills.

Reasoning through a problem requires an understanding between verbal and <u>nonverbal</u> ideas.

When you use reasoning skills and past experience to brainstorm ideas you are <u>generating solutions.</u>

When you narrow down solution ideas, then select the best one, you are engaging in <u>decision making</u>.

<u>OAmalOHopeO</u>

8 0
3 years ago
Read 2 more answers
Other questions:
  • When troubleshooting firewalls, which of the following is not something you should do after you attempt a fix?
    7·1 answer
  • Define a Python function named file_listers with two parameters. The first parameter will be a string specifying the name of the
    7·1 answer
  • Arun is 5 years older than Anu. five years ago, the ratio of their ages was 3:2 . find their present age​
    10·2 answers
  • I’m nobody. Who are you?
    9·2 answers
  • What’s the difference between the logical and physical structure of a file? What are the advantages of not having an application
    15·1 answer
  • Which is a good guideline to follow for adding animation to a presentation?
    12·1 answer
  • I will mark you Brainliest if you could guess how old i am :3
    9·1 answer
  • Am I correct? Please help
    7·1 answer
  • Which option describes a balanced slide?
    11·1 answer
  • a company is using aws fargate to run a batch job whenever an object is uploaded to an amazon s3 bucket. the minimum ecs task co
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!