Math::N...acciWord(3)
π Math::N...acciWord(3) β the Fibonacci Word, bestie edition π
okay so this is a User Contributed Perl Documentation page, and the module is literally called Math::NumSeq::FibonacciWord. yes the header abbreviates it like Math::N...acciWord(3) because man pages love drama and truncation. anyway. sit down, hydrate, let's talk about 0s and 1s π«Ά
β¨ NAME β¨
Math::NumSeq::FibonacciWord β 0/1 related to Fibonacci numbers π
πΈ SYNOPSIS πΈ
use Math::NumSeq::FibonacciWord;
my $seq = Math::NumSeq::FibonacciWord->new;
my ($i, $value) = $seq->next;
that's it. that's the whole vibe. make the object, call next, receive destiny β¨
π¦ DESCRIPTION π¦
so this is a sequence of 0s and 1s, and it's formed from the Fibonacci numbers. iconic behaviour, no notes.
0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, ...
starting i=0
the first two values are 0,1. then β and this is the part that ate β Fibonacci number F(k) many values get copied from the start to extend it, and you do that over and over. it's giving "copy your own homework but make it sacred geometry":
0,1 initial
0,1,0 append 1 value
0,1,0,0,1 append 2 values
0,1,0,0,1,0,1,0 append 3 values
0,1,0,0,1,0,1,0,0,1,0,0,1 append 5 values
0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1,0 append 8 values
etc
π§ Morphism
you get the exact same sequence if you start with 0 and then just keep expanding, like a glow-up applied repeatedly:
0 -> 0,1
1 -> 0
that's the whole morphism. lowkey elegant. highkey obsessed.
π₯ Fibbinary and Zeckendorf
plot twist bestie: this is also the Fibbinary numbers modulo 2, which is literally the least significant bit of the Zeckendorf base representation of i. yes. that's a real sentence. we're thriving.
the Zeckendorf base breakdown keeps subtracting Fibonacci numbers F(k) until you land on 0 or 1. this effectively undoes that append-expansion procedure from up top. (there's more on this in "Zeckendorf Base" in Math::NumSeq::Fibbinary, go read it iykyk.)
start at i
until i=0 or i=1 do
subtract from i the largest Fibonacci number <= i
final resulting i=0 or i=1 is Fibonacci word value
example time, because numbers are cuter with context: for i=11, the largest Fibonacci number <=11 is 8, subtract that and you're left with 3. from 3, the largest Fibonacci <=3 is 3 itself, subtract that and you land on 0 β which is the Fibonacci word value for i=11. math said slay π
π Dense Fibonacci Word
the option fibonacci_word_type => "dense" selects the dense Fibonacci word:
1,0,2,2,1,0,2,2,1,1,0,2,1,1,...
starting i=0
this is the plain word from before, except each two values (not overlapping) get encoded in a binary style like this:
plain pair dense value
---------- -----------
0,0 0
0,1 1
1,0 2
for example, the Fibonacci word starts 0,1, so the dense form starts 1. and a pair 1,1 never occurs in the plain Fibonacci word, so there's no value 3 in the dense form. periodt. π
π FUNCTIONS π
heads up: check out "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all sequence classes. this is just the local lore.
$seq = Math::NumSeq::FibonacciWord->new ()$seq = Math::NumSeq::FibonacciWord->new (fibonacci_word_type => $str)
create and return a shiny new sequence object π«Ά. the fibonacci_word_type option is a string and it can be either of these:
"plain" (the default)
"dense"
β Iterating
$seq->seek_to_i($i)β move the current i so thatnext()will return$i(and the corresponding value) on the next call. little time-travel moment, we love to see it.
π Random Access
$value = $seq->ith($i)β return the$i'th value in the sequence. and bestie, the first value is ati=0, not 1. don't embarrass us.$bool = $seq->pred($value)β return true if$valueoccurs in the sequence. this simply means 0 or 1 β or, for the dense Fibonacci word, 0, 1 or 2. simple as that fr fr.
π SEE ALSO π
Math::NumSeq, Math::NumSeq::Fibonacci, Math::NumSeq::Fibbinary
Math::PlanePath::FibonacciWordFractal
go click around, it's a whole ecosystem π
π HOME PAGE π
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020, 2022 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
okay that's the whole page bestie, you're officially fluent in Fibonacci word π
and that's the tea, mwah π β this was perl v5.42.0, dated 2025-07-25, from Math::N...acciWord(3). she's a 2025 girlie and she ate, no cap. πβ¨
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms