Implement recursive functions in C++

factorial using recursion

#include <iostream>

using namespace std;

int factorial(int n){
if(n == 0){
return 1;
}else{
return n * factorial(n-1);
}
}

int main(){
int n;
cout << "Enter the number: ";
cin >> n;
cout << "The factorial of " << n << " is " << factorial(n);
}


fibonacci series using recursion

// fibbonacci series using recursion

#include <iostream>

using namespace std;

int fibbo(int n){
if(n == 0){
return 0;
}else if(n == 1){
return 1;
}else{
return fibbo(n-1) + fibbo(n-2);
}
}

int main(){
int n;
cout << "Enter the number: ";
cin >> n;
cout << "The fibbonacci series is: ";
for(int i=0; i<n; i++){
cout << fibbo(i) << " ";
}
}