$29.99
Reading
Read Chapter 10 in Introduction to Computing using Python: An Application Development Focus, Second Edition by Ljubomir Perković.
Logistics
You need to do this assignment on a computer which has Python 3 installed on it. Python 3.8.5 download page can be found here.
A submission that includes code which does not run will not get any points for the part unless specifically documented reason of the error.
Assignment
1. Recursion (80pts)
In this part, you must use recursion to solve the problems. No iteration of any kind is allowed (no loops, list comprehension, lambda, etc.). No recursion, no points.
a. (30pts) Write a function natureNumbers(n) that prints the first n natural numbers using recursion.
b. (50pts) You have come up with a new idea for encrypting two texts: you mix them, by alternating between them, e.g. hello and world become hweolrllod (colors just so you can tell where each letter comes from). Write a function alt(s,t) that uses recursion to mix two strings s and t in this way and returns the result. Check that s and t have the same length, otherwise return immediately an empty string.
2. Run Time Analysis (20pts)
Develop two versions of factorial function to calculate n!:
1) factorial(n): using iteration technique. 2) factorialRecur(n): using recursion.
Then compare the run time of these two versions when calculating factorial of a very large number.
Submission
Submit the assignment using Assignment 7 folder. You can choose to either submit each solution in separate files or in one single file.