Calculates factorial using recursion.