Namara

Code daily. Without assist.

Today's code

-- haskell/fix

factorial :: Integer -> Integer
factorial n = n * factorial (n - 1)

This never terminates. Fix it.

Answer

There's no base case, so it recurses forever — past zero, into negative numbers, without ever stopping. Add factorial 0 = 1 as a separate equation before the recursive case.