by SoftTalker · 2y ago · 0 comments
It's absurd to actually compute it that way, but it's beautiful to express it that way.
From the blog post:
def fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
Easy to read, easy to comprehend. You just need a smart compiler to do it efficiently."Accidentally Quadratic" was a fun tumblr dedicate to more real world instances of this, and it's sad they're not longer posting, though I still use that term to name real-world sightings of O(lol) time. (O(lol) space is just called "Java".)
¹and since you say "to actually compute it that way", I think you get this, but I want to point it out here
And, well, if you disregard heavy optimizations, then this "insanely-recursive" function is actually a somewhat decent way to measure the efficiency of the function calls and arithmetic.