A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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?

  • This Question is Closed
  1. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    can you see how this works? http://dpaste.com/693798/

  2. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hint: 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(n-1) print factorial(t) def fib(n): if n==0: <----base case return 0 elif n==1: <----base case return 1 else: return fib(n-1)+fib(n-2) <---rule print fib(t)

  3. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 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

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.