Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Fibonacci broj.
- */
- #include <iostream>
- using namespace std;
- int rfib (int broj)
- {
- if (broj <= 2 && broj >0) return 1;
- if (broj == 0) return 0;
- return rfib(broj - 1) + rfib(broj - 2);
- }
- int main(){
- int broj;
- cout << "Unesite 1 broj: ";
- cin >> broj;
- cout << "Fibonaci broj od: " << broj << " je " << rfib(broj) << endl;
- system("pause>null");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement