elixir_channels_demo/lib/demo/funcs.ex~

11 lines
192 B
Elixir
Raw Permalink Normal View History

2022-04-07 17:28:36 +00:00
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