I'm pretty new to coding and currently have the following problem: I'm supposed to calculate the product of all numbers up to a certain number (basicly faculty) but I'm supposed to ignore all numbers that I can divide by 9 and the number 13. Also all numbers above 22 shall return -1. I wrote the following code, but it does not ignore the value 13 and I don't know why.
long long product(int val)
{
if (val == 1)
return 1;
if (val <= 0 || val > 22)
return -1;
else
{
if (val % 9 == 0 || val == 13) {
printf("if %d \n", val);
return product(val - 1);
}
else
{
printf("else %d \n", val);
return val * product(val - 1);
}
}
}
Printf were done to see whether or not it took the else or if without debugger.