Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 11, 2019 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e58c5549b3e26525946068b525050dff to your computer and use it in GitHub Desktop.
Save parzibyte/e58c5549b3e26525946068b525050dff to your computer and use it in GitHub Desktop.
Factorial iterativo created by parzibyte - https://repl.it/@parzibyte/Factorial-iterativo
=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