Math::NumSeq::SqrtContinuedPeriod -- period of the continued fraction for sqrt(i)
use Math::NumSeq::SqrtContinuedPeriod; my $seq = Math::NumSeq::SqrtContinuedPeriod->new; my ($i, $value) = $seq->next;
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.
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).
sqrt($s)
$value = $seq->ith ($i)
Return the period of sqrt($i).
Math::NumSeq
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::NumSeq
CPAN shell
perl -MCPAN -e shell install Math::NumSeq
For more information on module installation, please visit the detailed CPAN module installation guide.