3 ms·
> A coworker, learning about this blog concept, remarked that “accidentally quadratic” is less exciting than, say, accidentally factorial. But I’ve never seen o
by maaaats 12y ago
> A coworker, learning about this blog concept, remarked that “accidentally quadratic” is less exciting than, say, accidentally factorial. But I’ve never seen one of those in production software, either.
Not production code, but when learning about recursion at uni someone implemented fibonacci like
fib (a) { return fib(a-1) + fib(a-2) }
(with a base case, obviously). So fib(6) would generate calls to fib(5) and fib(4), which would spawn calls to fib(4), fib(3) and fib(3), fib(2). Those 4 would again spawn 2 new calls each, many of them overlapping.
- wcrichton 12y agoAlthough thankfully that's still not factorial :-)
- titanomachy 12y agoExponential?