Skip to content

Instantly share code, notes, and snippets.

@edipofederle
Created January 1, 2011 13:50
Show Gist options
  • Select an option

  • Save edipofederle/761761 to your computer and use it in GitHub Desktop.

Select an option

Save edipofederle/761761 to your computer and use it in GitHub Desktop.
def fatorial(n)
raise "Argumento invalido" if n < 1
return 1 if n == 1
n * fatorial(n-1)
end
puts fatorial(5)
puts fatorial(4)
puts fatorial(10)
puts fatorial(-4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment