++ed by:

2 PAUSE users

Kevin Ryde


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


 use Math::NumSeq::ReReplace;
 my $seq = Math::NumSeq::ReReplace->new;


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


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.



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


Math::NumSeq, Math::NumSeq::ReRound




Copyright 2012, 2013, 2014 Kevin Ryde


