4 ms·
Iterative methods for calculating factorials also "fail for quite small numbers" in most common languages (basically, anything without built-in bignums). The c
by Turing_Machine 4y ago
Iterative methods for calculating factorials also "fail for quite small numbers" in most common languages (basically, anything without built-in bignums).
The cause of failure in this case has nothing to do with recursion.
- Taniwha 4y agoalso you want to teach: why is iterative factorial faster than recursive? and , why do some (arbitrarily) large recursive factorials crash while the iterative equivalent just takes a long time ? (stack overflow) IMHO we don't teach compsci kids enough about the costs of things - new vs. * for example
- bigbacaloa 4y agoI didn't express myself well. That naive computations of factorials are useless for computing 50! is a useful lesson. It's also useful to learn that despite the love of recursion among computer scientists, in practice it's barely if ever a good idea.