Skip to content

Instantly share code, notes, and snippets.

@timyates
Created May 11, 2012 15:13
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 timyates/c4714fb484c2ca291f2b to your computer and use it in GitHub Desktop.
Save timyates/c4714fb484c2ca291f2b to your computer and use it in GitHub Desktop.
small factorial closure
final factorial = { final int n ->
return (n == 0) ? 1 : n * { owner.call(n - 1) }()
}
assert factorial( 5 ) == 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment