To (again) merely add a little curlicue to zapashcanon’s work, I think his point is that to make it tail-recursive, you need to add more than one auxiliary parameter. And just figuring that stuff out, can be a little tricky. Whereas, if you’re programming in a language like ML (or Scheme) you can convert to CPS in a VERY straightforward way (his words “almost only syntactic” are very correct these days, with the lovely method of Danvy) and so you can get a version that is tail-recursive (and hence, uses constant stack space) in a straightforward manner.
SkySkimmer gives us the tail-recursive version with multiple auxiliary parameters, and I suspect that if one were to
(a) start with the original version
(b) CPS it in a tidy manner
© then apply “defunctionalization”
one could arrive at SkySkimmer’s version. But of course, that’s tedious, time-consuming, and liable to error. Just writing in CPS and letting the compiler do a somewhat-decent job, can get you most of the way to the efficiency of SkySkimmer’s version.