Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Sascha Peilicke

By: a guest on Oct 19th, 2009  |  syntax: C++  |  size: 0.24 KB  |  hits: 247  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. int fib(unsigned int n)
  2. {
  3.     if (n == 0) {
  4.         return 0;
  5.     } else if (n == 1) {
  6.         return 1;
  7.     } else {
  8.         return fib(n - 1) + fib(n -2);
  9.     }
  10. }
  11.  
  12. int main(void)
  13. {
  14.     fib(5);
  15.     fib(20);
  16.     return 0;
  17. }