fibonacci sock almost ruined my date
APR 05, 2026
inkhaven
click here to skip to the math.
finding the sock
My partner and I were on a date in Sausalito, a quiet seaside town north of the Bay, when we came across this sock (at a sock store).

I personally assume that all code on clothing is nonsense until proven otherwise, so I got ready to make a joke about it, except that this program…actually does something.
Here, take a look:
1fn main() {
2 let root = 5_F32.0;
3 let phi = (1.0 + root)/2;
4 for n in 0.16 {
5 print!('{}', (phi.pow(n)/root).round());
6 }
7}
8
As we've hinted at in the title, this program computes the first 16 Fibonacci numbers (in Rust!). These are the numbers you get when you start with terms and (or sometimes and ) and add the previous two terms to get the next term. You can see that the program output across the back of the ankle,
is indeed the first couple of terms of the Fibonacci sequence.
To compute these numbers, the program is using something called Binet's formula.2 Binet's formula says that the th Fibonacci number is
where
It was pretty easy to get here with a quick Wikipedia search, after which I tried very hard to be like "well, that's cool and all, I guess I'll update my priors about code on apparel, but now we can move on…"
except that my brain was like...!!! where does this formula come from???? what does it all mean???? And despite the romantic vibe and beautiful seaside view, I was not able to let it go.
nerd-sniped
The idea goes something like this: we know that the Fibonacci numbers satisfy the recurrence relation
with the initial conditions
Here's the general plan:
- Do some guessing to find a family of sequences that satisfies the recurrence relation in .
- Hope that one of them satisfies the initial conditions in .
We know that the Fibonacci sequence grows at least exponentially, since the sequence more than doubles every two terms. So let's try guessing3 that some exponential sequence satisfies the relation in , say where and are fixed real numbers. Then says that
which means that
Then we know that either , or
This polynomial4 might look familiar to you. Indeed,
are its roots! This means we actually have two families of sequences satisfy the Fibonacci relation in . These are
where are some constants.
We also easily check that the sum of the two,
also satisfies the relation in .
Now that we've got a nice family of sequences that satisfy , let's see if any of them satisfy the initial conditions in . We should have that
and
Simplifying a bit, we see that
and
We can solve this system of equations, and we get that
Plugging it all back in, we see that the sequence
satisfies the recurrence relation in and the initial conditions in . That means that this sequence is the sequence of Fibonacci numbers! So we win, and this is why Binet's formula works!5
Getting here took a lot of animated yapping, and I imagine that everyone around thought that we were crazy. But hey, I understood it eventually, and the date wasn't even ruined! We got some ice cream, watched some boats, and managed not to miss the sunset.
e, thanks for telling me to write this.
footnotes
-
I spent far too long finding this photo because it turns out that searching "Binet's formula code sock" doesn't exactly work. I went to the sock store's Google Maps page and found the name of a company that make these novelty socks (it was the wrong one), realized I could google "novelty socks" and visited a couple novelty sock websites, continued looking until I realized that I probably should have tried "Fibonacci code sock", and finally tracked it down. ↩
-
Though, the program ignores the term because is small enough to safely ignore if you're rounding to the nearest integer. ↩
-
à la solving differential equations ↩
-
This polynomial is called the characteristic polynomial of the linear recurrence relation. ↩
-
Of course, this is not the only way to get to Binet's formula. I personally like the linear algebra approach better, where you can see that and are the eigenvalues of the matrix corresponding to the recurrence relation. ↩