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]
2 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]2 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
Which part of the cryosphere comes directly from the atmosphere?
marin [14]
The answer to this question is C.
4 0
3 years ago
Read 2 more answers
If AL contains binary 1000 1111, which one will show the information of the binary bits in AL after performing operation SHR AL,
padilas [110]

Answer:

a) AL will contains 0011 1100

Explanation:

In assembly language, shifting bits in registers is a common and important practice. One of the shifting operations is the SHR AL, x where the x specifies that the bits be shifted to the right by x places.

SHR AL, 2 therefore means that the bits contained in the AL should be shifted to the right by two (2) places.

For example, if the AL contains binary 1000 1111, the SHR AL, 2 operation will cause the following to happen

Original bit =>                                        |   1  |  0 |  0  |  0  |  1 |  1 |  1 |  1 |

Shift once to the right =>                |  1 |   0 |  0  |  0  |  1 |  1 |  1 |  1 | (0) |

Shift once to the right =>          |  1 |  0 |  0  |  0  |  1 |  1 |  1 |  1 | (0) | (0) |

Notice;

(i) that there are two shifts - one at a time.

(ii) that the bits in bold face are the bits in the AL after the shift. Those that in regular face are those in the carry flag.

(iii) that the new bits added to the AL after a shift are the ones in bracket. They are always set to 0.

5 0
2 years ago
Which measure should you take for the periodic maintenance of your computer?
WITCHER [35]
I believe the answer is annual maintenance
Hope this helps :p
6 0
3 years ago
Read 2 more answers
Drag the words into the correct boxes
tresset_1 [31]

Explanation:

if you have any doubts or queries regarding the answer please feel free to ask

4 0
2 years ago
As Kaydence reads a chapter in her anthropology text, she draws a network diagramming the relationships among the concepts descr
german

Answer:

visual encoding

Explanation:

According to my research on the three types of encoding methods, I can say that based on the information provided within the question Kaydence is best described as capitalizing on visual encoding. Which is the act of associating a certain something with a picture in order to store it into memory, as opposed of associating it with sound or words. In this situation Kaydence is associating it with a networking diagram she drew.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Other questions:
  • Categories of functions specified by computer instruction?
    11·1 answer
  • Yahoo! allows users to create personalized my yahoo! pages. users can add or delete a variety of information from their personal
    8·2 answers
  • Describe some advantages of a 64-bit versus 32-bit version of windows.
    9·1 answer
  • Your instructor has asked you to perform some research regarding a computer OS capability of distinguishing spoken words. What i
    14·1 answer
  • Many computer magazines and Web sites present comparisons of several DBMSs. Find one such DBMS comparison article and compare th
    10·1 answer
  • What natural resource are available on the coast but not somewhereelse
    13·1 answer
  • Lindsey also needs to calcite the commissions earned each month. If the company earns $200,000 or more in a month, the commissio
    5·1 answer
  • Informed _________ will better manage complexities and enable more efficient manufacturing of goods.
    13·1 answer
  • Does anyone have Rblx? if so write your username
    6·1 answer
  • There is overlap in the subjects of study in the different information technology disciplines.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!