开发者

Fibonacci Recursion [closed]

开发者 https://www.devze.com 2023-03-14 17:16 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何学运维 Closed 11 years ago.

Alright, so I've tried to search for it, and yes, I found the answer, but not the explanation of it, I'd like to know the explanation of the following result:

 float fib(int num)
    {
      float  result;

      if (num==1)
         result=0;
      else
          {
        if (num==2)
            result=1;
        else
            result=fib(num-1)+fib(num-2);
          }

      return result;
    }


Start here: http://en.wikipedia.org/wiki/Recursion
Then go here: http://en.wikipedia.org/wiki/Fibbonaci_Series


The method called fib() calls itself in certain cases, and does not call itself in other cases (known as base cases).

0

精彩评论

暂无评论...
验证码 换一张
取 消