NAME

Math::NumSeq::SqrtDigits -- the digits of a square root

SYNOPSIS

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

DESCRIPTION

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.)

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence 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).

$bool = $seq->pred($value)

Return true if $value might occurs as a digit in the square root.

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?

BUGS

The current code requires Math::BigInt bsqrt(), which may mean BigInt 1.60 or higher (which comes with Perl 5.8.0 and up).

SEE ALSO

Math::NumSeq, Math::NumSeq::SqrtEngel, Math::NumSeq::FractionDigits

Norman L. de Forest, "The Square Root of 4 to a Million Places", at Project Gutenberg, http://www.gutenberg.org/ebooks/3651

HOME PAGE

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

LICENSE

Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016 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/>.