🌀 Fibonacci Game
Source: Notion task “Publish the Fibonacci Game site on the public site” (private notes) · code in fib-game/ · built 2026-11-24

🌈 Happy

Adds the last two numbers and celebrates every result.

Method
Lazy generator with BigInt
Language
Node.js
Cost per term
O(1) additions per term, exact arbitrary-size integers
Display
Rainbow golden spiral
Furthest term
F(94) = 19,740,274,219,868,223,167
Folder
fib-game/happy/
Pane
Happy's show

How it works

A JavaScript generator function (function*) yields one term at a time. It keeps only the last two numbers and adds them: a, b = b, a + b. BigInt keeps every value exact, so the run reaches F(94) with no overflow.

The display

A rainbow tiling of Fibonacci squares. Each new term adds a square, and a spiral of dots and sparkles curves through them. The picture rescales to fit the pane as the squares grow, and a cheerful caption changes as it goes.

Pick a moment in the 75-second run. Each frame is a real colour capture of the pane.

Happy's show · t = 5 s
                   •••✦         •••••                       
                 •••                +·✦                     
                ••  5                  ••                   
               ••                       •••                 
               *                   8      ••                
               •      1  1                 ••               
               ••         •                ••               
                +·3    2 ·✦                 •               
                 •••••••••                  •               
                                            •               
                                            •               
                                            •               
                                           ••               
                                          ✦••               
                                          ✦*                
                                         ·✦                 
                             13         +·                  
Sunflowers and pinecones approve!
n=7  F(7)=13
Happy's show · t = 10 s
                          •••                               
                        ••                                  
                      ••                                    
                     ••     233                             
                    ••                                      
                   ••                                       
                  +•                                        
                  +·                                        
                  +                                         
                  +                                         
                  •              34   •·•                   
                  ••                 55 ••                  
                  ••                     •                  
                   ••* 144              ••                  
                     *+             89  ✦*                  
                      ••••            •••                   
                         •••••+•••+••••                     
Each number is the sum of the two before. Neat!
n=13  F(13)=233
Happy's show · t = 20 s
                               •••*+•                       
                           ••••                             
                         •••                                
                       •••                                  
                      ••                                    
                     ✦*    75025                            
                    ·✦                                      
                    •                                       
                    •                                       
                    •                                       
                    •           •••••••                     
                    •           •      •                    
                    ·✦                 •                    
                    ·✦•46368           •                    
                      ••         28657••                    
                        •••         ••*                     
                           •·✦•••✦•••                       
Round and round we go!
n=25  F(25)=75025
Happy's show · t = 35 s
  •                                   •✦•••✦•••             
  •                                •••         •••          
  •                               ·✦              ·✦        
  ••                              •        267914296••      
  ••                              •                 ••      
   ✦*                             ·•                 •      
   ✦*+                             ••+•              •      
    *+                                               •      
     +·✦     701408733                               •      
      •••                                           ••      
        ••                                         •••      
          ••                           433494437  •••       
           •••                                   +·         
              •••                              ✦*+          
                 ••••                        •••            
                    ••••*+               ••••               
                          ·••••••••••+•••                   
Spiralling with joy!
n=44  F(44)=701408733
Happy's show · t = 50 s
                   ••••         •••••                       
                 ·✦•                •••                     
                ••                     ••                   
               ••                       ••✦                 
               •             4052739537881✦*                
               *                           *+               
               ••                          ••               
                ••       ••                 •               
                 ••*••✦••·                  •               
                                            •               
                                            •               
                                           ••               
                                           ••               
                                          •••               
                                          ••                
                                         ••                 
                       6557470319842    ••                  
Sunflowers and pinecones approve!
n=63  F(63)=6557470319842
Happy's show · t = 65 s
                               ••••••                       
                           +·••                             
                         ✦*+                                
                       •••                                  
                      ••                                    
                     37889062373143906                      
                    ••                                      
                    •                                       
                    •                                       
                    •                                       
                    •           •✦•••••                     
                    •           •      •                    
                    ••                 +                    
                    •••                •                    
                      ••              ••                    
                        •✦*         •••                     
                           •••••·•••·                       
Round and round we go!
n=81  F(81)=37889062373143906
Happy's show · t = 72 s
                   ••••✦*•••••••••                          
               ••••               •✦*+·•                    
            *+·                        ••••                 
          ••*                              •••              
         ••                                   •••           
       •••                                      ••          
      •••                                         ••        
      ••                                           •••      
      •                         2880067194370816120 •••     
      •                                               ••    
      •              •·••                             •••   
      •                 ••                             •*   
      ••                 +                              *+  
      •••                •                              *+  
        ••              ••                               +  
          •✦*         •••                                +  
             •••••••••                                   +  
So many colours, so much maths!
n=90  F(90)=2880067194370816120

The core code

From fib-game/happy/fib.js:

function* fibonacci() {
  let a = 0n, b = 1n;
  for (;;) {
    yield a;
    [a, b] = [b, a + b];
  }
}

Run and check

fib-game/happy/run.sh            # the display, about 75 s
fib-game/happy/run.sh --verify   # first 30 terms and F(90) against known values

Limits and notes

← GrumpySleepy →