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;
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.
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.
power
power=>3
$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.
$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.
$value
Math::NumSeq, Math::NumSeq::MobiusFunction
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.