Question
1. Given the arithmetic sequence: -1, 4, 9, a. Write a Python recursive function that will return to the program that invokes it the nth
1. Given the arithmetic sequence: -1, 4, 9,
a. Write a Python recursive function that will return to the program that invokes it the nth term in the sequence above.
b. Write a Python program outside the function that prompts the user to enter an integer n, which represents the number of terms desired. The program will include a for loop in which the Loop Control Variable (LCV) is designated as i.
The program will invoke the function n times, each time passing the current value of the LCV and receiving back from the function the appropriate term, which the program will print using: print (Term # , i = , term ). The program will also sum the first n terms and print the sum.
c. Test the program when n = 8. d. Modify your function so that it becomes a function that will run an infinite number of times. Explain what you have done.
d. Modify your function so that it becomes a function that will run an infinite number of times. Explain what you have done.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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