Calculate factorials using recursion.