search.cpan.org is shutting down
Kevin Ryde > Math-NumSeq > Math::NumSeq::Squares

Math-NumSeq-72.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 72

# NAME

Math::NumSeq::Squares -- perfect squares

# SYNOPSIS

``` use Math::NumSeq::Squares;
my \$seq = Math::NumSeq::Squares->new;
my (\$i, \$value) = \$seq->next;```

# DESCRIPTION

The sequence of squares i**2,

`    0, 1, 4, 9, 16, 25, ...`

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

`\$seq = Math::NumSeq::Squares->new ()`

Create and return a new sequence object.

## Iterating

`\$seq->seek_to_i(\$i)`

Move the current sequence position to `\$i`. The next call to `next()` will return `\$i` and corresponding value.

`\$seq->seek_to_value(\$value)`

Move the current sequence position so that `next()` will give `\$value` on the next call, or if `\$value` is not a square then the next square above `\$value`.

## Random Access

`\$value = \$seq->ith(\$i)`

Return `\$i * \$i`.

`\$bool = \$seq->pred(\$value)`

Return true if `\$value` is a square, ie. k*k for some integer k.

`\$i = \$seq->value_to_i_ceil(\$value)`
`\$i = \$seq->value_to_i_floor(\$value)`

Return the square root of `\$value`, rounded up or down to the next integer.

`\$i = \$seq->value_to_i_estimate(\$value)`

Return an estimate of the i corresponding to `\$value`.

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