fix issue where calculating 0! never terminates

This commit is contained in:
Caleb Webber 2025-03-06 20:56:37 -05:00
parent f11fdc77fc
commit 4acecad41a

View file

@ -13,6 +13,8 @@ defmodule Euler.Algebra do
@doc """
Computes n!
"""
def fact(0), do: 1
def fact(1), do: 1
def fact(n), do: fact(n - 1, n)
defp digit_sum(0, acc), do: acc