Math::NumSeq::PowerPart -- largest square root etc divisor
use Math::NumSeq::PowerPart; my $seq = Math::NumSeq::PowerPart->new (power => 2); my ($i, $value) = $seq->next;
This sequence is the largest integer whose square is a divisor of i,
1, 1, 1, 2, 1, 1, 1, 2, 3, ... starting i=1
For example at i=27 the value is 3 since 3^2=9 is the largest square which is a divisor of 27. Notice the sequence value is the square root, ie. 3, of the divisor, not the square 9.
When i has no square divisor, ie. is square-free, the value is 1. Compare the
MobiusFunction where value 1 or -1 means square-free. And conversely
MobiusFunction is 0 when there's a square factor, and PowerPart value here is > 1 in that case.
power parameter selects what power divisor to seek. For example
power=>3 finds the largest cube dividing i and the sequence values are the cube roots.
power=>3 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, ...
For example i=24 the value is 2, since 2^3=8 is the largest cube which divides 24.
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::PowerPart->new ()
$seq = Math::NumSeq::PowerPart->new (power => $integer)
Create and return a new sequence object.
$value = $seq->ith($i)
Return the largest perfect square, cube, etc root dividing
This calculation requires factorizing
$i and in the current code after small factors a hard limit of 2**32 is enforced in the interests of not going into a near-infinite loop.
$bool = $seq->pred($value)
Return true if
$value occurs in the sequence, which is simply any integer
$value >= 1.
Copyright 2011, 2012, 2013, 2014 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/>.