Skip to content

Instantly share code, notes, and snippets.

@johnwesonga
Last active May 6, 2022 18:03
Show Gist options
  • Save johnwesonga/eb427b0fc10c83c9e3241f13042ca03d to your computer and use it in GitHub Desktop.
Save johnwesonga/eb427b0fc10c83c9e3241f13042ca03d to your computer and use it in GitHub Desktop.
Factorial in Elm
import Html exposing (text)
fact : Int -> Int
fact n =
case n of
0 -> 1
1 -> 1
_ -> n * fact(n-1)
factorial : Int -> Int
factorial n =
if n < 1 then
1
else
n * factorial(n-1)
main =
fact 3 |> String.fromInt |> text
@dullbananas
Copy link

facts first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment