CS101 - HW5 Prelab

Review the notes from class this week and complete this prelab before lab on Thursday / Friday.

Create your file, add proper comments

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.

[5 points] Add stubs and documentation for all functions

Add "stubs" (i.e., empty function definitions that you will finish in lab and for homework) for each of the functions you'll write for this homework. After completing this step, your file should already have comments at the top of the file and for each function definition, and the file will compile without errors.

[5 points] Greatest Common Divisor

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.

What should be in the file

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.