Skip to content

Instantly share code, notes, and snippets.

@tirthankarkundu17
Last active January 28, 2021 12:00
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 tirthankarkundu17/11d63fc85864c940bcc7ee0419b35ea2 to your computer and use it in GitHub Desktop.
Save tirthankarkundu17/11d63fc85864c940bcc7ee0419b35ea2 to your computer and use it in GitHub Desktop.
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