Source: Notion task βPublish the Fibonacci Game site on the public siteβ (private notes) Β· code in
fib-game/ Β· built 2026-11-24π Grumpy
Squares a matrix. Complains about it.
- Method
- 2Γ2 matrix exponentiation
- Language
- C
- Cost per term
- O(log n) 2Γ2 matrix products, fixed-width 64-bit integers
- Display
- Grumpy scoreboard
- Furthest term
- F(93), the largest value that fits in 64 bits, then it starts again at F(0)
- Folder
fib-game/grumpy/- Pane
- Grumpy's show
How it works
The matrix Q = [[1,1],[1,0]] raised to the power n holds F(n+1), F(n) and F(nβ1). Repeated squaring gets QβΏ in about logβ n matrix products. Grumpy uses plain uint64 arithmetic, so the largest exact term is F(93) = 12,200,160,415,121,876,738.
The display
A stadium scoreboard. It prints the matrix QβΏ, then F(n) in big block digits, then a new grumpy remark on every tick. A countdown runs at the bottom.
Pick a moment in the 75-second run. Each frame is a real colour capture of the pane.
Grumpy's show Β· t = 5 s
GRUMPY SCOREBOARD n = 7
Q^7 =
β‘ 21 13 β€
β£ 13 8 β¦
F(7)
β βββ
β β
β βββ
β β
β βββ
Add the last two. Again. Riveting.
70s left. Ctrl+C if you must.Grumpy's show Β· t = 10 s
GRUMPY SCOREBOARD n = 14
Q^14 =
β‘ 610 377 β€
β£ 377 233 β¦
F(14)
βββ βββ βββ
β β β
βββ β β
β β β
βββ β β
Yes, it's still growing. Shocking.
65s left. Ctrl+C if you must.Grumpy's show Β· t = 20 s
GRUMPY SCOREBOARD n = 28
Q^28 =
β‘ 514229 317811 β€
β£ 317811 196418 β¦
F(28)
βββ β βββ βββ β β
β β β β β β β
βββ β β βββ β β
β β β β β β β
βββ β β βββ β β
Is it 75 seconds yet?
55s left. Ctrl+C if you must.Grumpy's show Β· t = 35 s
GRUMPY SCOREBOARD n = 49
Q^49 =
β‘ 12586269025 7778742049 β€
β£ 7778742049 4807526976 β¦
F(49)
βββ βββ βββ βββ βββ β β βββ βββ β β βββ
β β β β β β β β β β β β β β β
β β β βββ β βββ βββ β β βββ βββ
β β β β β β β β β β β β
β β β βββ β β βββ βββ β βββ
Yes, it's still growing. Shocking.
41s left. Ctrl+C if you must.Grumpy's show Β· t = 50 s
GRUMPY SCOREBOARD n = 71
Q^71 =
β‘ 498454011879264 308061521170129 β€
β£ 308061521170129 190392490709135 β¦
F(71)
308061521170129
(too long for big digits. Typical.)
Don't look at me like that.
25s left. Ctrl+C if you must.Grumpy's show Β· t = 65 s
GRUMPY SCOREBOARD n = 92
Q^92 =
β‘ 12200160415121876738 7540113804746346429 β€
β£ 7540113804746346429 4660046610375530309 β¦
F(92)
7540113804746346429
(too long for big digits. Typical.)
I squared a matrix for this.
11s left. Ctrl+C if you must.Grumpy's show Β· t = 72 s
GRUMPY SCOREBOARD n = 8
Q^8 =
β‘ 34 21 β€
β£ 21 13 β¦
F(8)
βββ β
β β
βββ β
β β
βββ β
Sunflowers have it easy.
4s left. Ctrl+C if you must.The core code
From fib-game/grumpy/grumpy.c:
static Mat mul(Mat x, Mat y) {
Mat r = { x.a*y.a + x.b*y.c, x.a*y.b + x.b*y.d,
x.c*y.a + x.d*y.c, x.c*y.b + x.d*y.d };
return r;
}
/* Q^n by repeated squaring */
static Mat qpow(unsigned n) {
Mat r = {1, 0, 0, 1}, q = {1, 1, 1, 0};
while (n) {
if (n & 1) r = mul(r, q);
q = mul(q, q);
n >>= 1;
}
return r;
}
static uint64_t fib(unsigned n) { return (uint64_t)qpow(n).b; }
Run and check
fib-game/grumpy/run.sh # the display, about 75 s fib-game/grumpy/run.sh --verify # first 30 terms and F(90) against known values
Limits and notes
- Stops at F(93): F(94) does not fit in an unsigned 64-bit integer.
- Its --verify compares F(0)βF(93) with Python instead of reaching F(100).