Skip to content

Instantly share code, notes, and snippets.

@tirthankarkundu17
Last active January 28, 2021 12:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Tail Recursion in Dataweave2
%dw 2.0
fun tailFactorial(n:Number, prod:Number = 1) =
(if(n == 1 or n == 0)
prod
else
tailFactorial(n-1, (prod * n)))
output application/json
---
tailFactorial(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment