Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Design a function called sum_fibonacci_sequence that takes an integer n a returns the sum of the first n values in the Fibonacci sequence.
1. Design a function called sum_fibonacci_sequence that takes an integer n a returns the sum of the first n values in the Fibonacci sequence. The function should assume the integer passed as an argument is not negative. Recall: The Fibonacci Sequence is a series of numbers constructed as follows: The first two numbers in the sequence are 0 and 1 The next number in the sequence is found by adding up the two numbers before it (0+1=1) The first 7 values in the sequence are: 0, 1, 1, 2, 3, 5 and 8 and so the sum of the first 7 values would be 20 Examples: sum_fibonacci_sequence (0) should return the value 0 as there are no numbers in the sequence is: sum_fibonacci_sequence (1) should return the value 0 as the first number in the sequence is: 0 sum_fibonacci_sequence (9) should return the value 54 as the first 9 number in the sequence are: 0, 1, 1, 2, 3, 5, 8, 13 and 21 which add up to 54 2. Design a function called get_factors that an integer and returns a string containing all of the factors of that number from smallest to biggest separated by commas (,). The format of your returned string must be formatted with exactly as demonstrated in the examples below with a comma between each value and no additional white space or trailing commas. The function should assume the integer passed as an argument is greater than 0. Examples: If the function is called as: get_factors (1) the function should return the value: '1' If the function is called as: get_factors (12) the function should return the value: 1,2,3,4,6,12' TIP: think about the is_multiple function you wrote in Assignment 2 3. Design a function called factorial that takes an integer and computes and returns the factorial of that integer. The function should assume the integer passed as an argument is not negative. Recall the factorial of n (n!) is computed as: n! = n* (n-1) * (n-2)(n-3) There are other ways to compute the factorial, but to receive full marks on this question your implementation must use the formula shown above. 21
Step by Step Solution
★★★★★
3.52 Rating (145 Votes )
There are 3 Steps involved in it
Step: 1
The designs for the three functions youve requested in Python 1 sumfibonaccisequ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started