int factorial(int n) {
    if (n <= 1) {
        return 1;
    }
    return n * factorial(n);
}

void main() {
    IO.println(factorial(5));
}

// From Groundwork, chapter 12 (ch12-recursion-and-problem-solving), box 2.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch12_02.java
// This fails on purpose: it throws java.lang.StackOverflowError—This recursion never reaches its base case, so it calls itself until Java runs out of room and stops the program. It crashes on purpose: the error is the lesson.
