Kevin Ryde > Math-NumSeq-65 > Math::NumSeq::PisanoPeriod

Math-NumSeq-65.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 65   Source   Latest Release: Math-NumSeq-69

# NAME

Math::NumSeq::PisanoPeriod -- cycle length of Fibonacci numbers mod i

# SYNOPSIS

``` use Math::NumSeq::PisanoPeriod;
my \$seq = Math::NumSeq::PisanoPeriod->new;
my (\$i, \$value) = \$seq->next;```

# DESCRIPTION

This is the length cycle of Fibonacci numbers modulo i.

```    1, 3, 8, 6, 20, 24, 16, 12, 24, 60, 10, 24, 28, 48, 40, ...
starting i=1```

For example Fibonacci numbers modulo 4 repeat in a cycle of 6 numbers, so value=6.

```   Fibonacci  0, 1, 1, 2, 3, 5, 8,13,21,34,55,89,144,...
mod 4      0, 1, 1, 2, 3, 1, 0, 1, 1, 2, 3, 1, 0,...
\--------------/  \--------------/  \---
repeating cycle of 6```

The Fibonaccis are determined by a pair F[i],F[i+1] and there can be at most i*i many different pairs mod i, so there's always a finite repeating period. Since the Fibonaccis can go backwards as F[i-1]=F[i+1]-F[i] the modulo sequence is purely periodic, so the initial 0,1 is always part of the cycle.

# FUNCTIONS

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

`\$seq = Math::NumSeq::PisanoPeriod->new ()`

Create and return a new sequence object.

## Random Access

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

Return the Pisano period of `\$i`.

http://user42.tuxfamily.org/math-numseq/index.html