//recursive function (works properly)
int factorial(int n, int acc = 1)
{
if (n == 1)
return acc;
elsereturn factorial(n - 1, acc*n);
}
//converting recursive function into a loop (not working)
int factorial(int n)
{
int acc = 1;
for (; n > 1; --n){
acc *= n;
return acc;
}
}