-
-
Save pulkit110/cdf5341405d36a945faf6882b187c96d to your computer and use it in GitHub Desktop.
Fibonacci Number Generator in Elixir - Buggy
This file contains 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 number(n) do | |
fib1 = 0 | |
fib2 = 1 | |
2..n |> Enum.each(fn _i -> | |
fib = fib1 + fib2 | |
fib1 = fib2 | |
fib2 = fib | |
end) | |
fib2 | |
end | |
end | |
Fib.number(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment