7.5 Homework
Professor: I guess it’s time we call it a day. For homework you write a program that
compute s and writes out the greatest common divisor (GCD) of two integers. The
GCD of two integers, as you might recall from high school mathematics, is th e largest
positive integer that evenly divides both numbers. You use the Euclidean algorithm,
which is fairly simple and straightfor ward :
Read two integers.
Repeat as long as they are different:
Calculate the absolute difference between both num bers.
Replace the larger number by the absolute diffe rence calculated in the pre-
vious step.
End Repeat
Here both numbers are equal. They are also equal to th e GCD of the two integers
entered at the beginning.
Lastly, here is a list of today’s keywords:
In this meeting: expre ssion, statement, semicolon, order of execution, flowchart,
processing step, decision, expressions with side effect, compound statem ent, code
indentation, conditional, if/else, truthy value, falsy value, loop, while, debug-
ging, br eakpoint, watch, step, type conversions, explicit conversions
146 Meeting 7. Controlling Program Flow