There have been numerous discussions about this particular rewriting in julia. Here is one of them: Tail-call recursion