Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int fibonacci(int n) {
- if(n <=1)
- return 1;
- else
- return fibonacci(n - 1) + fibonacci(n - 2);
- }
- int main(int argc, char *argv[])
- {
- int num;
- cout << "inserire N: " << endl;
- cin >> num;
- cout << "fibonacci: " << fibonacci(num) << endl;
- cout << "Press the enter key to continue ...";
- cin.get();
- cin.get();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement