Advertisement
Guest User

FIbo

a guest
Oct 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int fibo(int n)
  4. {
  5.     if (n <= 1)
  6.         return n;
  7.     else
  8.         return fibo(n - 1) + fibo(n - 2);
  9. }
  10. int main()
  11. {
  12.     int n;
  13.     int s = 0;
  14.     for (int i = 1; i <= 100; i++)
  15.         s += fibo(i);
  16.     cout << s;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement