Skip to content

Instantly share code, notes, and snippets.

@robhinds
Created October 5, 2013 20:22
Show Gist options
  • Save robhinds/6845597 to your computer and use it in GitHub Desktop.
Save robhinds/6845597 to your computer and use it in GitHub Desktop.
def factorial ={ n, accumulator=1 ->
if (n == 1) accumulator
else factorial.trampoline(n-1, n*accumulator)
}.trampoline()
factorial(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment