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]
2 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]2 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
L what is 67000 rounded to the nearest ten thousand
Aleks04 [339]

The next larger ten thousand is  70,000 .
The next smaller ten thousand is  60,000 .
67,000  is closer to  70,000  than it is to  60,000 .
So  70,000  is the nearest ten thousand.

8 0
2 years ago
Read 2 more answers
How does the y-intercept appear in these three representations: table,equation,and graph?
devlian [24]
In a table it's  EXAMPLE: Cars/Drivers the cars is x and the drivers is y(y-intercept). In an equation, EXAMPLE using y=mx+b the b is the y-int., and in a graph it is (x,y) the y being the y-int.
6 0
3 years ago
Read 2 more answers
A simple random sample of 36 men from a normally distributed population results in a standard deviation of 10.1 beats per minute
Katyanochek1 [597]

Answer:

Step-by-step explanation:

Given that:

sample size n = 36

standard deviation = 10.1

level of significance ∝ = 0.10

The null hypothesis and the alternative hypothesis can be computed as follows:

H_0 : \sigma = 10

H_1 : \sigma \neq 10

The test statistics can be computed as follows:

X^2 = \dfrac{(n -1)s^2 }{\sigma ^2}

X^2 = \dfrac{(36 -1)10.1^2 }{10^2}

X^2 = \dfrac{(35)102.01 }{100}

X^2 = \dfrac{3570.35 }{100}

X^2 =35.704

degree of freedom = n - 1 = 36 - 1 = 35

Since this test is two tailed .

The P -value can be determined by using the EXCEL FUNCTION ( = 2 × CHIDIST(35.7035, 35)

P - value = 2 × 0.435163515

P - value = 0.8703      ( to four decimal places)

Decision Rule : To reject the null hypothesis if  P - value is less than the 0.10

Conclusion: We fail to reject null hypothesis ( accept null hypothesis) since p-value is greater than 0.10 and we conclude that there is sufficient claim that the normal range of pulse rates of adults given as 60 to 100 beats per minute resulted to a standard deviation of 10 beats per minute.

3 0
3 years ago
No link or bot answer right
Margaret [11]

Answer:

1/6^8

Step-by-step explanation:

the answer is the one right next to the submit answer

3 0
2 years ago
What is the equation of the line that passes through the point (-3,2) and has a slope of -2/3
Nookie1986 [14]

Answer:

Y=-2/3x+0

This is the answer I found

8 0
3 years ago
Other questions:
  • A rectangular prism with a volume of
    15·1 answer
  • The amount of money paid out of earnings that is divided among shareholders.
    6·1 answer
  • Please help i will mark brainly
    5·2 answers
  • Does y=5x squared+2x-1 have a min or max
    14·1 answer
  • The tail of the spider monkey is 64% of the length shown. What is the length of its tail. Length of spider monkey is 55 inches.
    11·1 answer
  • HELPPP THIS IS MY LAST QUESTION
    8·1 answer
  • Giving brainliest to the CORRECT answer
    15·1 answer
  • Raymond’s Bake Shop sold 26/1/2 dozen cupcakes on Saturday. On Friday,
    11·1 answer
  • Which equation has no solution? A 2(x+1)=1 B 2(x+1)=2x+2 C 2(x+1)=2x+1 D 2(x+1)=2
    5·1 answer
  • Margo wants to convince her father to change her curfew from 9 P.M. to 10 P.M. She gathers data on curfew times from a random sa
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!