macrofish

kokotina

Jan 5th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long double F(int n,long long int &kokotina)
  5. {
  6.    
  7.         kokotina+=1;
  8.         if (n==0)
  9.         return 0;
  10.         if (n==1)
  11.         return 1;
  12.         return F(n-1,kokotina)+ F(n-2,kokotina);
  13.  
  14. }
  15. /*
  16. long double fact(int n)
  17. {
  18.  
  19.         if (n==0)
  20.         return 0;
  21.         if (n==1)
  22.         return 1;
  23.         return n*fact(n-1);
  24.  
  25. }
  26. */
  27. int main()
  28. {
  29.     int n;
  30.     cout << "zadej cislo n" << endl;
  31.     cin >> n;
  32.     long long int kokotina =0;
  33.     cout << "fib cisla " << n << ":";
  34.     cout << F(n,kokotina) << endl;
  35.     cout << endl;
  36.  
  37.     cout << kokotina << endl;
  38. //  cout << "fact cisla " << n << ":";
  39. //  cout << fact(n)<< endl;
  40.  
  41.  
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment