A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
ps3, problem 2
Hello
How to solve problem 2 in ps3 recursively? 2 days are gone and there is no result. I am fascinated with recursion but I gave up. Would you please show the way?
anonymous
 4 years ago
ps3, problem 2 Hello How to solve problem 2 in ps3 recursively? 2 days are gone and there is no result. I am fascinated with recursion but I gave up. Would you please show the way?

This Question is Closed

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0can you see how this works? http://dpaste.com/693798/

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Hint: All recursive functions follow a typical pattern. First, define the base case. The base case is where the recursion will stop. Second, specify the rule which is followed in each step other than the base case. Below I have defined a recursive function for generating factorials and fibonnaci numbers. The fibonnaci definition is slightly trickier since it requires two base cases. def factorial(n): if n==1: <base case return n else: <rule return n * factorial(n1) print factorial(t) def fib(n): if n==0: <base case return 0 elif n==1: <base case return 1 else: return fib(n1)+fib(n2) <rule print fib(t)

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0@malpaso I am familiar with concept and these examles. But somehow your explanation gave me energy to give one more try. Thank you. @bwCA. Thank you very much
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.