Kevin Ryde > Math-NumSeq-63 > Math::NumSeq::PowerPart

Math-NumSeq-63.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 63   Source   Latest Release: Math-NumSeq-69

# 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

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

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.

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

# FUNCTIONS

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.

## Random Access

`\$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`.

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