# NAME

Math::NumSeq::SqrtContinued -- continued fraction expansion of a square root

# SYNOPSIS

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

# DESCRIPTION

This is terms in the continued fraction expansion of a square root. It approaches the root by

``````                      1
sqrt(S) = a + -----------
a +   1
-----------
a +   1
----------
a + ...``````

The first term a is the integer part of the root, leaving a remainder 0 < r < 1 which is expressed as r=1/R with R > 1

``````                     1
sqrt(S) = a + ---
R``````

Then a is the integer part of that R, and so on recursively.

Values a onwards are always a fixed-period repeating sequence. For example sqrt(14) is a=3 and then 1,2,1,6 repeating. For some roots a single value repeats. For example sqrt(2) is a=1 then 2 repeating. See SqrtContinuedPeriod for just the length of the period.

# FUNCTIONS

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

`\$seq = Math::NumSeq::SqrtContinued->new (sqrt => \$s)`

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

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

Return the i'th term in the continued fraction, starting from i=0 for the integer part of the sqrt.

`\$i = \$seq->i_start ()`

Return 0, the first term in the sequence being i=0.

Math::ContinuedFraction