this post was submitted on 09 Nov 2025
448 points (97.1% liked)
Lifehacks
206 readers
466 users here now
Efficiency in all walks of life.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
This is such a cool example of how some recursive algorithms have a closed form. We all know that there's a simple equation to plug miles into to get kilometers, but we don't talk about how the Fibonacci sequence has a closed form. This is so cool.
Wjat does closed form mean? Asking as a stupid botanist, sorry.
Closed form means it can be written out as a specific, finite set of instructions that work the same regardless of what the input to your function is.
For Fibonacci, it is most commonly defined in its recursive form:
But using this form, computing a very large Fibonacci number requires computing all the numbers before it, so it’s not the same finite set of instructions for every number, it takes more computation to generate larger numbers.
However, there is a closed form formula for generating Fibonacci numbers. Using this formula, you can directly compute any large Fibonacci number without having to compute all those intermediate steps. It takes the same amount of work to compute any Fibonacci number.
(Note that a and b here are constants; I only wrote them separately to avoid a mess of nested parenthesis)
For an example of something that doesn’t have a closed form, we do not know of a closed form for generating prime numbers. There are several known algorithms for generating the nth prime number, but they all depend on computing all the previous prime numbers, making it very difficult to compute very large prime numbers (in fact, how generating large primes is actually done is by making an educated guess and then checking that it’s actually prime). Discovering a closed form formula for prime numbers would have a huge impact on mathematics and cryptography.