Last active
December 22, 2015 02:48
-
-
Save parroty/6405497 to your computer and use it in GitHub Desktop.
Fibonacci number
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 Sequence do | |
| def fib(0), do: 1 | |
| def fib(1), do: 1 | |
| def fib(n), do: fib(n - 1) + fib(n - 2) | |
| end | |
| IO.puts Sequence.fib(10) # -> 89 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment