Created
January 11, 2019 16:54
-
-
Save parzibyte/e58c5549b3e26525946068b525050dff to your computer and use it in GitHub Desktop.
Factorial iterativo created by parzibyte - https://repl.it/@parzibyte/Factorial-iterativo
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 | |
Programa en Ruby que calcula el factorial | |
de un número de manera iterativa | |
@author parzibyte | |
=end | |
def factorial(numero) | |
factorial = 1 | |
while numero > 1 do | |
factorial = factorial * numero | |
numero -= 1 | |
end | |
factorial | |
end | |
50.times do |numero| | |
puts "El factorial de #{numero} es #{factorial numero}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment