Skip to content

Instantly share code, notes, and snippets.

@pulkit110
Last active September 30, 2021 08:56
Show Gist options
  • Save pulkit110/cdf5341405d36a945faf6882b187c96d to your computer and use it in GitHub Desktop.
Save pulkit110/cdf5341405d36a945faf6882b187c96d to your computer and use it in GitHub Desktop.
Fibonacci Number Generator in Elixir - Buggy
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