3 ms·
For someone just starting out they would get stuck on this very first problem, it involves recursion. People 'get' recursion, but coding it is something differe
by sergiotapia 7y ago
For someone just starting out they would get stuck on this very first problem, it involves recursion. People 'get' recursion, but coding it is something different.
- gbear605 7y agoIt doesn’t need recursion, you can do a while(round(x/3)-2 > 0) type thing, but recursion is simpler.
- tialaramex 7y agoNothing 'needs' recursion, it's always equivalent to an iterative solution. In some languages a recursive solution is more natural and may perform better.
- moron4hire 7y agoI know of languages that can automatically convert some kinds of recursive code into the iterative equivalent automatically, but I've never seen one that can make the recursive version faster than an iterative equivalent.
- sergiotapia 7y agoAh true, i just naturally reach for it in elixir
- empath75 7y agoI just knocked out a non-recursive solution in 9 lines of python in five minutes.