Checking the arguments and the result buffer is not done this time for simplicity. However, the terminating condition of the recursion still needs to be checked:
Checking argument and result buffer sizes is the same as in the C example. Also, the terminating condition of the recursion still needs to be checked:
Note that there is no need to do error checking everywhere, since errors are reported as exceptions. In this example there is only a single try/catch block in the main function: