Menu

[Solved]1 Given Sequence 1 2 4 8 Write Python Recursive Function Named F N Return Nth Term Sequen Q37174322

1. Given the sequence: -1, 2,-4,8 a. Write a Python recursive function named f(n) that will return the nth term in the sequen

1. Given the sequence: -1, 2,-4,8 a. Write a Python recursive function named f(n) that will return 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, “-“, tern). The program will also sum the first n terms and print the sum. c. Test the program when n 6. Submit the output. d. Modify your function so that it becomes a function that will run an infinite number of times. Explain what you have done. Show transcribed image text 1. Given the sequence: -1, 2,-4,8 a. Write a Python recursive function named f(n) that will return 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, “-“, tern). The program will also sum the first n terms and print the sum. c. Test the program when n 6. Submit the output. d. Modify your function so that it becomes a function that will run an infinite number of times. Explain what you have done.

Expert Answer


Answer to 1. Given the sequence: -1, 2,-4,8 a. Write a Python recursive function named f(n) that will return the nth term in the s… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *