Created
January 14, 2019 18:53
-
-
Save parzibyte/35a2b48712f631c295b857619a3587c2 to your computer and use it in GitHub Desktop.
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
=begin | |
Sucesión de fibonacci con ciclos | |
en Ruby | |
@author parzibyte | |
=end | |
def fibonacci(posicion) | |
siguiente = 1 | |
actual = 0 | |
(1..posicion).each do | |
# Si quieres imprimir la sucesión, simplemente descomenta lo siguiente: | |
#puts actual | |
siguiente, actual = siguiente + actual, siguiente | |
end | |
actual | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment