Created
February 2, 2015 09:45
-
-
Save thluiz/dedaec5c5faba40b3a7b to your computer and use it in GitHub Desktop.
The simplest fibonacci implementation
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 Fibonacci do | |
def calc(0), do: 1 | |
def calc(1), do: 1 | |
def calc(n) when n > 0, do: calc(n-2) + calc(n-1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment