# CSS220- Module 9 Assignment

**CSS 220 Module 9 Homework**

**Deliverable: **

**Submit a separate Python file for each problem below.****Submit an answer to the question in problem 2.**

- Complete the following Python program to compute the sum 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 recursively:

def sum(x):

# don’t forget your base case

# recursively compute and return

print(sum(10))

- Revise the Fibonacci program from class so that it asks the user for which Fibonacci number he or she wants. Then use this value to instead in the program. Try out your program to compute the 10th, 20th, 30th and 40th Fibonacci numbers.
**Why does it take so much longer to computer the higher Fibonacci numbers?** - We can determine how many digits a positive integer has by repeatedly dividing by 10 (without keeping the remainder) until the number is less than 10, consisting of only 1 digit. We add 1 to this value for each time we divided by 10. Here is the recursive algorithm:

1. If n < 10 return 1.

2. Otherwise, return 1 + the number of digits in n/10 (ignoring the fractional part).

Implement this recursive algorithm in Python and test it using three separate calls with the values 15, 105, and 15105. (HINT: Remember that if n is an integer (data type), n/10 will be an integer without the fractional part.)