#include using namespace std; int Fun(int x) { int sum=1; if(x>1) sum=x*Fun(x-1); else return sum; } int main() {
When your program pass in the if condition, no return statement finish the function. The number you got is the result of an undefined behavior.
if
int Fun(int x) { int sum=1.0; if(x>1) sum=x*Fun(x-1); else return sum; return x; // return something here }