The recursive solution is prettier, but it's not doing any less work and it ties up more memory unless your language supports tail recursion (python doesn't)
I try to avoid recursive solutions for problems like these unless the solution specifically needs back tracking.
Never heard of tail recursion before. I'll look it up, thanks.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.