CSS 220 NLU Fibonacci Numbers & Growth Rates Python Programming Worksheet

User Generated

unynyshfvba

Programming

CSS 220

National Louis University

CSS

Description

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:
  • 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:

def sum(x):

# don’t forget your base case

# recursively compute and return

print(sum(10))

Unformatted Attachment Preview

CSS 220 Module 9 Homework Deliverable: - Submit a separate Python file for each problem below. - Submit an answer to the question in problem 2. 1. 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)) 2. 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? 3. 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.)
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hi, the assignment has been...


Anonymous
Just the thing I needed, saved me a lot of time.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Related Tags