Source: Notion task “Publish the Fibonacci Game site on the public site” (private notes) · code in
fib-game/ · built 2026-11-24😴 Sleepy
Uses a formula so it never has to count. Still falls asleep.
- Method
- Binet's closed form
- Language
- bash + bc
- Cost per term
- One high-precision power per term (precision grows with n)
- Display
- Sleepy night sky
- Furthest term
- F(24) = 46,368 (slow on purpose: it is sleepy)
- Folder
fib-game/sleepy/- Pane
- Sleepy's show
How it works
Binet's formula gives F(n) directly: F(n) = round(φⁿ / √5), where φ = (1 + √5) / 2. Sleepy asks bc for n/4 + 20 decimal digits, which is enough for the rounding to be exact. No earlier terms are needed.
The display
A night sky with a crescent moon, twinkling stars and drifting z's. Numbers are typed out slowly, one character at a time, then float up and fade. A status line counts down to dawn.
Pick a moment in the 75-second run. Each frame is a real colour capture of the pane.
Sleepy's show · t = 5 s
sleepy fibonacci ~ binet's closed form .. . _.._ . + . .' .-' . . | ( . . '. '-. `''` Z z . . + . . . . . . . z . . . F(0) = 0 . . . Z z . F(1) = 1 . . F(2_ n=2 scale=20 bc -l dawn in 71s
Sleepy's show · t = 10 s
sleepy fibonacci ~ binet's closed form .. . _.._ . . . .' .-' . . | ( . . '. '-. `''` F(0) = 0 . . z Z z . . * .F(1) = 1 . . . . Z z . + . F(2) = 1 . . . . . z z F(3) = 2 . . F(4) = n=4 scale=21 bc -l dawn in 65s
Sleepy's show · t = 20 s
sleepy fibonacci ~ binet's closed form .. . _.._ F(3) = 2 * . .' .-' . . | ( .F(4) = 3 . '. '-. `''` . . + . . z Z z . . . . . . z Z z . . ...*yawn*... F(5) = 5 . . . . F(6) z z . . F(7) = _ n=7 scale=21 bc -l dawn in 56s
Sleepy's show · t = 35 s
sleepy fibonacci ~ binet's closed form .. . _.._ . * . .' .-' . . | ( .F(9) = 34 . '. '-. `''` . z Z z . F(10) = 55 + . . + . . F(11) = 89z Z z . . . . . . . z . . . ...*yawn*... F(1 n=12 scale=23 bc -l dawn in 41s
Sleepy's show · t = 50 s
sleepy fibonacci ~ binet's closed form .. . _.._ F(13) = 233 * . .' .-' . . | ( . . '. '-. F(14) = 377 `''` . . * . . z +F(15) = 610 . . . . . z z . . F(16) = 987 . . . . F(17) = 1597 Z z . . F(1 n=18 scale=24 bc -l dawn in 26s
Sleepy's show · t = 65 s
sleepy fibonacci ~ binet's closed form .. . _.._ . * . .' .-' . . | ( . . '. '-. `''` . z . ...*yawn*... F(19) = 4181 . . + . . F(20) = 6765z z . . . . . . . z z . F(21) = 10946 . . F(22) = n=22 scale=25 bc -l dawn in 11s
Sleepy's show · t = 72 s
sleepy fibonacci ~ binet's closed form .. . _.._ . . . .' .-' . . | ( . . '. '-. F(21) = 10946 `''` z . . . . . .F(22) = 17711 . . * + Z . . . . . F(23) = 28657Z z . . . F(24) = 46368 n=24 scale=26 bc -l dawn in 4s
The core code
From fib-game/sleepy/run.sh:
scale_for() { echo $(( $1 / 4 + 20 )); }
fib() { # Binet: round(phi^n / sqrt 5), high precision, then truncate x+0.5
local n=$1 s
s=$(scale_for "$n")
bc -l <<EOF
scale=$s
r=sqrt(5)
p=(1+r)/2
x=p^$n/r+0.5
scale=0
x/1
EOF
}
Run and check
fib-game/sleepy/run.sh # the display, about 75 s fib-game/sleepy/run.sh --verify # first 30 terms and F(90) against known values
Limits and notes
- A drifting z once drew over the last digit of a number (F(20) showed as 676Z for a moment). The Supe left it as is.
- Precision is tested up to F(300).