Kevin Ryde > Math-NumSeq > Math::NumSeq::ReReplace

Math-NumSeq-72.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 72

# NAME

Math::NumSeq::ReReplace -- sequence of repeated replacements

# SYNOPSIS

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

# DESCRIPTION

This is a sequence by David Madore formed by repeatedly replacing every N'th occurrence of a term with N.

`    1, 2, 1, 2, 3, 3, 1, 2, 4, 4, 3, 4, ...`

As per

David Madore, "have you seen this sequence?", sci.math.research, 24 Oct 2004, http://sci.tech-archive.net/Archive/sci.math.research/2004-10/0218.html

## Stages

The generating procedure begins with all 1s,

`    stage 0: 1,1,1,1,1,1,1,1,1,1,1,1,...`

Then every second 1 is changed to 2

`    stage 1: 1,2,1,2,1,2,1,2,1,2,1,2,...`

Then every third 1 is changed to 3, and every third 2 changed to 3 also,

`    stage 2: 1,2,1,2,3,3,1,2,1,2,3,3,...`

Then every fourth 1 becomes 4, every fourth 2 becomes 4, and every fourth 3 becomes 4.

`    stage 3: 1,2,1,2,3,3,1,2,4,4,3,4,...`

The replacement by N of every Nth is applied separately to the 1s, 2s, 3s etc remaining at each stage.

The optional `stage => \$n` parameter limits the replacements to a given number of stages of the algorithm. The default -1 means unlimited.

# FUNCTIONS

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

`\$seq = Math::NumSeq::ReReplace->new ()`
`\$seq = Math::NumSeq::ReRound->new (stages => \$integer)`

Create and return a new sequence object.

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

Return true if `\$value` occurs in the sequence. This merely means integer `\$value >= 1`.

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