The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::PowerPart -- largest square root etc divisor

SYNOPSIS

 use Math::NumSeq::PowerPart;
 my $seq = Math::NumSeq::PowerPart->new (power => 2);
 my ($i, $value) = $seq->next;

DESCRIPTION

The largest integer whose square is a divisor of i,

    1, 1, 1, 2, 1, 1, 1, 2, 3, ...

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 root, ie. 3, of the divisor, not the square as such.

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 Option

The 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. At i=24 the value is 2, since 2^3=8 is the largest cube qhich divides 24.

FUNCTIONS

$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 $i.

The current code relies on factorizing $i and a hard limit of 2**32 is placed on $i 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.

SEE ALSO

Math::NumSeq, Math::NumSeq::MobiusFunction