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
.
SEE ALSO
Math::NumSeq, Math::NumSeq::ReRound
HOME PAGE
http://user42.tuxfamily.org/math-numseq/index.html
LICENSE
Copyright 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.