# CMU 15-112 Spring 2016 Quiz8 Practice (Due never)

• Quiz8 will include a subset of the problems here.

1. Recursion Notes Examples
You should understand all the worked examples in these notes:
1. digitSum(n)
2. fib(n)
3. gcd(x,y)
4. factorial(n)
5. isPrime(n) and nthPrime(n)
6. vowelCount(s)

2. sumOfOdds(L) (recursive)
Without using iteration, write the recursive function sumOfOdds(L) that takes a list of integers and returns the sum of the odd numbers in that list.

3. hasConsecutiveDigits(n) (recursive)
Without using iteration, write the recursive function hasConsecutiveDigits(n) that takes a possibly- negative int value n and returns True if that number contains two consecutive digits that are the same, and False otherwise.

4. min(L) (recursive)
Without using iteration, and without using the builtin min function or any other similar builtin function, write the recursive function min(L) that takes a list L of integers and returns the minimum value in the list.

5. isPerfectNumber (recursive)
Without using iteration, write the recursive function isPerfectNumber that takes a possibly-negative integer n and returns True if it is a perfect number and False otherwise, where a number is perfect if it is the sum of its positive divisors less than itself. For example, 6 is perfect because 6 = 1 + 2 + 3. Also, 28 is perfect because 28 = 1 + 2 + 4 + 7 + 14. The next one is 496, then 8128.

6. betterDotsDemo (with OOP)
You should be very clear on how to convert dotsDemo into betterDotsDemo, as covered in lecture (and in these notes).