Skip to content

Instantly share code, notes, and snippets.

@phucnguyen81
Last active July 3, 2018 01:58
Show Gist options
  • Select an option

  • Save phucnguyen81/8262961b028feb31049e6d1f80650353 to your computer and use it in GitHub Desktop.

Select an option

Save phucnguyen81/8262961b028feb31049e6d1f80650353 to your computer and use it in GitHub Desktop.
Fibonacci sequence in ruby
def fibonacci_upto(max)
i1, i2 = 1, 1
while i1 <= max
yield i1
i1, i2 = i2, i1+i2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment