End of recursion:
$when::
sample.factorial (n == 0
)
. (payload
=1
)
Main recursion rule:
$when::
sample.factorial (n > 0
)
sample.factorial (n=(n - 1))
. (payload
=(payload * n)
)
In pseudocode, it would look like this:
if(n == 0) fact = 1;
else fact = n * fact(n-1)
You need to log in to post a comment!