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
elena-14-01-66 [18.8K]
3 years ago
12

The recursive algorithm given below can be used to compute gcd(a, b) where a and b are non-negative integer, not both zero. proc

edure gcd(a, b) if a > b then gcd(a, b) := gcd(b, a) else if a = 0 then gcd(a, b) := b else if a = 1 then gcd(a, b) := 1 else if a and b are even then gcd(a, b) := 2gcd(a/2, b/2) else if a is odd and b is even then gcd(a, b) := gcd(a, b/2) else gcd(a, b) := gcd(a, b − a) Use this algorithm to compute (a) gcd(124, 244) (b) gcd(4424, 2111).
Mathematics
1 answer:
Delvig [45]3 years ago
8 0

Coding the given algorithm in python 3, the <em>greatest</em> <em>common </em><em>divisor</em><em> </em>of the values (124 and 244) and (4424 and 2111) are 4 and 1 respectively.

The program implementation goes thus :

def gcd(a, b):

<em>#initialize a function named gcd which takes in two parameters</em>

if a>b:

<em>#checks if a is greater than b</em>

return gcd (b, a)

<em>#if true interchange the Parameters and Recall the function</em>

elif a == 0:

return b

elif a == 1:

return 1

elif((a%2 == 0)and(b%2==0)):

<em>#even numbers leave no remainder when divided by 2, checks if a and b are even</em>

return 2 * gcd(a/2, b/2)

elif((a%2 !=0) and (b%2==0)):

<em>#checks if a is odd and B is even</em>

return gcd(a, b/2)

else :

return gcd(a, b-a)

<em>A</em><em> </em><em>sample</em><em> </em><em>run</em><em> </em><em>if</em><em> </em><em>the</em><em> </em><em>program</em><em> </em><em>on</em><em> </em><em>the</em><em> </em><em>values</em><em> </em><em>given</em><em> </em><em>:</em>

print(gcd(124, 244))

print()

<em>#leaves a space after the first output</em>

print(gcd(4424, 2111))

Learn more :brainly.com/question/25506437

You might be interested in
3(-4x + 8)= rewrite as expression
Lerok [7]

Answer:

-12x+24

Step-by-step explanation:

3(-4x+8)

multiply 3 by each part so 3(-4x) + 3(8)

-12x+24

6 0
3 years ago
Read 2 more answers
Simplify each expression.<br> (6x + 4x4 - 3x2) + (7x4 + 5x2 + 8x)
zepelin [54]

Answer:

simply add question

(11x^4 +2x^2 + 14x)

8 0
3 years ago
W<br><img src="https://tex.z-dn.net/?f=41%20%5Cdiv%20646%20%3D%20" id="TexFormula1" title="41 \div 646 = " alt="41 \div 646 = "
krek1111 [17]
This is your answer and for the multiplication I gave it to you step by step

3 0
2 years ago
Give an example of a polynomial that is a perfect square. How do you know that it is a perfect square? Give its factored form.
lora16 [44]

Answer:

Step-by-step explanation:

A polynomial is a  perfect square if has the form:

a^2+2ab+b^2

Its factored form is  (a+b)^2.

We can obtain examples by taking any value of a and b.

For example:

a=x  anb  b=2y.  

Thus we obtain a polynomial that is a perfect square:

x^2+2(x)(2y)+(2y)^2=x^2+4xy+4y^2

8 0
3 years ago
Which one is it, I’m having trouble with this one
Svet_ta [14]

Answer: I believe ur right

Step-by-step explanation:

6 0
3 years ago
Other questions:
  • In the above figure, m∠P = 120° and m∠Q = 5x. If angles P and Q are supplementary angles, what is the value of x and the measure
    5·1 answer
  • What is 1.23 pounds written as a mixed number
    10·2 answers
  • Lucy makes 4/7 of a dress in 3/4. How many dresses does she make in one hour
    13·1 answer
  • What is the value of 7/3 % 5/6
    14·1 answer
  • You’ll get Brainliest and 10 points
    15·1 answer
  • Help with at 3 please 20 Points
    13·1 answer
  • Help asap i’ll give brainliest
    5·1 answer
  • Which is the rationalized form of the expression sqrtx/sqrtx+sqrt7
    8·1 answer
  • Help Help Help Help Help
    5·1 answer
  • 5 x (-4)-((-6)-7)<br> (The X means to multiply)
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!