Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- // f(1) = 2
- // f(n) = 2F(n - 1)
- using namespace std;
- int fun ( int n ){
- if ( n == 1 )
- return 2;
- else
- return 2 * fun( n - 1 );
- }
- int main()
- {
- int num;
- cout << "Inserire num: " << endl;
- do{
- cin >> num;
- }while(num < 2);
- cout << "Funzione: " << fun(num) << endl;
- cout << "Press the enter key to continue ...";
- system("pause >>null");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement