4 ms·
The fact that the recursive method for calculating factorials fails for quite small numbers is a good reason for teaching it. Also it's a good illustration of
by bigbacaloa 4y ago
The fact that the recursive method for calculating factorials fails for quite small numbers is a good reason for teaching it.
Also it's a good illustration of how useless recursion is in practice.
- Turing_Machine 4y agoIterative 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.