Math::NumSeq::FractionDigits -- the digits of a fraction p/q
use Math::NumSeq::FractionDigits; my $seq = Math::NumSeq::FractionDigits->new (fraction => '2/11'); my ($i, $value) = $seq->next;
The sequence of digits which are a given fraction. For example 1/7 in decimal, being 0.14285714...
1, 4, 2, 8, 5, 7, 1, 4, etc
The digits are always a repeating sequence of length no more than den-1. In fact if you want to cook up a repeating sequence a,b,c,a,b,c,etc then the fraction is abc/999. In a base other than decimal the "9" is radix-1, ie. the highest digit.
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::FractionDigits->new (fraction => $f)
$seq = Math::NumSeq::FractionDigits->new (fraction => $f, radix => $r)
Create and return a new sequence object giving the digits of $f. $f is a string "num/den", or a decimal "xx.yy",
$f
2/29 29.125 1.5/3.25
The default sequence values are decimal digits, or the radix parameter can select another base. (But the fraction parameter is still decimal.)
radix
fraction
If the numerator or denominator of the fraction is bigger than fits Perl integer calculations then Math::BigInt is used automatically.
Math::BigInt
Math::NumSeq, Math::NumSeq::SqrtDigits
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2010, 2011, 2012 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.