This code believes the factorial number n. Why, in order to calculate the factorial of N numbers N, is N * CalcFactorial (n-1)? Why is it just calcfactorial (n)?
Public Long CalcFactorial (int n) {
if (n == 0) Return 1;
RETURN N * CALCFACTORIAL (N - 1);
}
Answer 1, Authority 100%
This is recursion. Whenever the function comes to the RETURN block, it causes itself, but already with the army of N-1. And so until N is equal to 0. n == 0 This is an extreme case, then the function returns 1 and summarizes the previous results.
You should read more about how the Recursion . Perhaps it is also worth reading what factorial is if you ask such a question.