Skip to content

Instantly share code, notes, and snippets.

@edipofederle
Created January 1, 2011 14:38
Show Gist options
  • Select an option

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

Select an option

Save edipofederle/761781 to your computer and use it in GitHub Desktop.
def fatorial(n)
raise ArgumentError, "Esperava um argumento >= 1. Mas retornou #{n}", caller if n < 1
return 1 if n == 1
n * fatorial(n-1)
end
puts fatorial(-4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment