elixir_channels_demo/lib/demo/funcs.ex~
2022-04-07 19:28:36 +02:00

11 lines
192 B
Elixir

defmodule Funcs do
def fib(n) when not is_number(n) or n < 0, do: raise("arg!")
def fib(n), do: fib(0, 1, n)
def fib(a, b, 0), do: a
def fib(a, b, n), do: fib(b, a+b, n-1)
end