11 lines
192 B
Elixir
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
|