10 ms·
They introduce both a traditional factorial function and a naive Fibonacci function - it seems likely most enterprising students will overflow the stack. Odd t
by e12e 8y ago
They introduce both a traditional factorial function and a naive Fibonacci function - it seems likely most enterprising students will overflow the stack.
Odd that they don't (from a quick skim) seem to mention it at all? When they do hand wave a bit around stack frames (call trees)?
- abecedarius 8y agoA naive fib(n) only needs stack depth of about n -- it takes a long time but doesn't need to go very deep.
- e12e 8y agoYou're right about Fibonacci - a naive fib(1000) takes a long time to eventually overflow the stack in python. But fact(1000) quickly crashes. Which is a shame as python has a full(?) number tower and has no problem calculating 1000!