calculating the factorial