by Ricardo “Rudxain” Fernández Serrata
Version 5 (October 9, 2022)
Download (77 downloads)
This function can easily cause overflows of many kinds in many programming languages, so be careful.
As you can see, there is an obvious speed-memory killer, which is the tail-call (the subroutine at the bottom of the flow). That call is there because this is the verbatim definition.
The variables `out` and `n` can be merged into 1 var without affecting the computation. They aren't merged here because I wanted to preserve a copy of the original input argument (n) to print it when halting.
Tags: big math slow recursive recursion
Rate and review within the app in the Community section.