Hacker News new | past | comments | ask | show | jobs | submit login

It doesn’t need recursion, you can do a while(round(x/3)-2 > 0) type thing, but recursion is simpler.



Nothing 'needs' recursion, it's always equivalent to an iterative solution. In some languages a recursive solution is more natural and may perform better.


I 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.


Ah true, i just naturally reach for it in elixir




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: