Review the notes from class this week and complete this prelab before lab on Thursday / Friday.
From within the Thonny application, create a single Python file username_hw5.py with all your work for this assignment in it. Include a comment at the top with your name, the date and homework number, and your lab section.
One of the oldest algorithms, dating back to the 5th century BCE, is Euclid's algorithm for computing the greatest common divisor of two integers. It works as follows:
Write a function GCD(a,b)
that implements Euclid's
algorithm using a
recursive strategy. As usual, your function should not use
the input()
or print()
functions, but
rather should take the two integers as parameters and should return
a result. You can call your function from the console or write another
function that prompts for input and calls your function and reports
the result.
Your GCD() function should work for any two positive
integers sent as parameters.
For the prelab portion, you should have completed GCD()
,
and should have function stubs and docstrings for the following:
drawStairs()
,
drawStairsScene()
,
isPrime()
,
printPrimes()
,
GCD2()
,
caesar_encrypt()
,
firstPrimes()
, and
factors()
.
Each function should have a docstring,
and the top of the file should include a comment listing (at a
minimum) your name, the date and homework number, and your lab section.
In the next section of HW5, you'll add functionality
to the remaining functions.