Created
January 9, 2019 14:21
-
-
Save Tombarr/f8e080dcfca354304ff5b6bd26a4221e to your computer and use it in GitHub Desktop.
Fibonacci using Elixir Guards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Fib do | |
| def fibonacci(0), do: 1 | |
| def fibonacci(1), do: 1 | |
| def fibonacci(n) when n > 1 do | |
| fibonacci(n-1) + fibonacci(n - 2) | |
| end | |
| def fibonacci(_), do: nil | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment