You are viewing a single comment's thread. Return to all comments →
Elixir solution of the 'Fibonacci Numbers'
defmodule Solution do def fibonacci_n(n \\ 0) do case n do 1 -> 0 2 -> 1 n -> fibonacci_n(n-1) + fibonacci_n(n-2) end end def main do IO.gets("") |> String.trim |> String.to_integer |> fibonacci_n |> IO.puts end end Solution.main
Fibonacci Numbers
You are viewing a single comment's thread. Return to all comments →
Elixir solution of the 'Fibonacci Numbers'