How it works
Code:
public static int factorial(int n){ //stop if (n == 1){ return(1); } //recursion return(num * factorial(n-1)); }
Basically, by calling factorial (n), you will call factorial (n-1) until n == 1, in which it will return 1. This leads to a chain of n*n-1*n-2 etc etc etc until we hit the stop.