Question

a. Create a Python recursive function for the relation in #1. b. Create a Python program...

a. Create a Python recursive function for the relation in #1. b. Create a Python program that uses a for loop to repeatedly invoke the recursive function you created and to print each term up to and including a6. In your HW document Include a screen shot of the Python file that contains your function code and your program code. Include a screen shot of your IDLE output

#1) Find the first 6 terms of the recurrence relation given by a1 = -1, an = 2n – an-1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python 3 code

============================================================================================

def fun(n):
if n==1:
return -1
else:
return 2*n-fun(n-1)

for i in range(1,7):
print(i,' term is: ',fun(i))

============================================================================================

Output

Add a comment
Know the answer?
Add Answer to:
a. Create a Python recursive function for the relation in #1. b. Create a Python program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT