The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::SqrtContinuedPeriod -- period of the continued fraction for sqrt(i)

SYNOPSIS

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

DESCRIPTION

This the period of the repeating part of the continued fraction expansion of sqrt(i).

    0, 1, 2, 0, 1, 2, 4, 2, etc

For example sqrt(12) is 3 then terms 2,6 repeating, which is period 2.

                    1   
   sqrt(12) = 3 + ----------- 
                  2 +   1
                      -----------
                      6 +   1
                          ----------
                          2 +   1
                              ---------
                              6 + ...        2,6 repeating

All square root continued fractions like this comprise an integer part followed by repeating terms of some length. Perfect squares are an integer part only, nothing furhter, and the period for them is taken to be 0.

FUNCTIONS

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

$seq = Math::NumSeq::SqrtContinuedPeriod->new (sqrt => $s)

Create and return a new sequence object giving the Continued expansion terms of sqrt($s).

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

Return the period of sqrt($i).

SEE ALSO

Math::NumSeq