Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

gcd (). This function implements a well-known algorithm for computing the greatest common divisor of two integers. For example, god(27,6) = 3, since 3 is

image text in transcribed

image text in transcribed

gcd (). This function implements a well-known algorithm for computing the greatest common divisor of two integers. For example, god(27,6) = 3, since 3 is the largest integer that evenly divides 27 and 6. 1. Study the function, and write an appropriate doc-string for it. 2. Notice that the function prints to the console. It's a terrible design decision; it's nearly impossible to test console output from within Python. Before you test the function, modify the function to return the value instead. 3. Design test cases for this function. There are several equivalence classes of interest: - ab -b>a - a=b - What happens when a = 0 or b=0? Is this okay? You may need to do some research to figure this out Write test cases for function, considering the information above. = def ged(a, b): " Add the doc-string!" while a != b: if a >b: a = a - b else: b = b - a print(a)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions