and 1 contributors

# 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;``````

# DESCRIPTION

This is a sequence of 0s and 1s formed from the Fibonacci numbers.

``````    starting i=0
0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, ...``````

The initial values are 0,1 then Fibonacci number F(k) many values are copied from the start to extend, so

``````    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``````

The same sequence is had by starting with 0 and then repeatedly expanding

``````    0 -> 0,1
1 -> 0``````

The result is also the Fibbinary numbers modulo 2. This can be seen most easily from the Zeckendorf base interpretation of those numbers since the base breakdown there works backwards from the above expansion subtracting Fibonacci numbers F(k) until reaching 0 or 1. (See "Zeckendorf Base" in Math::NumSeq::Fibbinary.)

## Dense Fibonacci Word

Option `fibonacci_word_type => "dense"` selects the dense Fibonacci word

``    1,0,2,2,1,0,2,2,1,1,0,2,1,1,...``

This is the above plain word taken two values at a time encoded as

``````    plain    dense
0,0       0
0,1       1
1,0       2``````

For example the plain Fibonacci word starts 0,1 so the dense form starts 1. Adjacent 1,1 never occurs in the plain Fibonacci word, so there's no value 3 in the dense form.

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

`\$seq = Math::NumSeq::FibonacciWord->new ()`
`\$seq = Math::NumSeq::FibonacciWord->new (fibonacci_word_type => "dense")`

Create and return a new sequence object.

## Random Access

`\$value = \$seq->ith(\$i)`

Return the `\$i`'th value in the sequence. The first value is at i=0.

`\$bool = \$seq->pred(\$value)`

Return true if `\$value` occurs in the sequence, which simply means 0 or 1, or for the dense Fibonacci word 0, 1 or 2.

Math::PlanePath::FibonacciWordFractal