I'm trying to write an algorithm to calculate the factorial of a number using recursive function.
This is my code :
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;
int factorial(int n) {
cin >> n;
if (n == 1)
return 1;
return n*factorial(n - 1);
}
int main() {
int n = 0;
cout<<"Enter a number:";
cout << factorial(n);
return 0;
}
It does nothing and I don't know why, it only lets me to give the number, but it's not calculating.