Math::NumSeq::SqrtDigits -- the digits of a square root
use Math::NumSeq::SqrtDigits; my $seq = Math::NumSeq::SqrtDigits->new (sqrt => 7); my ($i, $value) = $seq->next;
The sequence of digits which are the square root of a given radicand. For example sqrt(2) in decimal 1, 4, 1, 4, 2, 1, etc, being 1.41421 etc.
The default is decimal, or a radix can be given. In the current code Math::BigInt is used. (For radix 2, 8 and 10 the specific digit conversion methods in BigInt are used, which might be faster than the general case.)
radix
Math::BigInt
See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.
$seq = Math::NumSeq::SqrtDigits->new (sqrt => $s)
$seq = Math::NumSeq::SqrtDigits->new (sqrt => $s, radix => $r)
Create and return a new sequence object giving the digits of sqrt($s).
sqrt($s)
$bool = $seq->pred($value)
Return true if $value might occurs as a digit in the square root.
$value
Currently this presumes all digits occur, so simply $value >= 0 and $value < $radix. For a perfect square this might be wrong, for a non-square do all digits in fact occur?
$value >= 0
$value < $radix
The current code requires Math::BigInt bsqrt(), which may mean BigInt 1.60 or higher (which comes with Perl 5.8.0 and up).
bsqrt()
Math::NumSeq, Math::NumSeq::SqrtEngel, Math::NumSeq::FractionDigits
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2010, 2011 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
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.