Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long double F(int n,long long int &kokotina)
- {
- kokotina+=1;
- if (n==0)
- return 0;
- if (n==1)
- return 1;
- return F(n-1,kokotina)+ F(n-2,kokotina);
- }
- /*
- long double fact(int n)
- {
- if (n==0)
- return 0;
- if (n==1)
- return 1;
- return n*fact(n-1);
- }
- */
- int main()
- {
- int n;
- cout << "zadej cislo n" << endl;
- cin >> n;
- long long int kokotina =0;
- cout << "fib cisla " << n << ":";
- cout << F(n,kokotina) << endl;
- cout << endl;
- cout << kokotina << endl;
- // cout << "fact cisla " << n << ":";
- // cout << fact(n)<< endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment