CS2
Recursion
8
Order is IMPORTANT!
npublic long factorial(int n) {
nreturn n*factorial(n-1);
nif (n == 0) {
nreturn 1;
n}
n}
nYou must put the base case before the recursive
npart of the definition or bad things will happen – in this case a stack overflow will result!