1Math::NumSeq::ReverseAdUdsSetrepCso(n3t)ributed Perl DocMuamtehn:t:aNtuimoSneq::ReverseAddSteps(3)
2
3
4
6 Math::NumSeq::ReverseAddSteps -- steps of the reverse-add algorithm to
7 reach palindrome
8
10 use Math::NumSeq::ReverseAddSteps;
11 my $seq = Math::NumSeq::ReverseAddSteps->new;
12 my ($i, $value) = $seq->next;
13
15 The number of steps to reach a palindrome by the digit "reverse and
16 add" algorithm. For example the i=19 is 2 because 19+91=110 then
17 110+011=121 is a palindrome.
18
19 At least one reverse-add is applied, so an i which is itself a
20 palindrome is not value 0, but wherever that minimum one step might end
21 up. A repunit like 111...11 reverse-adds to 222...22 so it's always 1
22 (except in binary).
23
24 The default is to reverse decimal digits, or the "radix" parameter can
25 select another base.
26
27 The number of steps can be infinite. In binary for example 3 = 11
28 binary never reaches a palindrome, and in decimal it's conjectured that
29 196 doesn't (and that is sometimes called the 196-algorithm). In the
30 current code a hard limit of 100 is imposed on the search - perhaps
31 something better is possible. (Some binary infinites can be recognised
32 from their bit pattern ...)
33
35 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
36 classes.
37
38 "$seq = Math::NumSeq::ReverseAddSteps->new ()"
39 "$seq = Math::NumSeq::ReverseAddSteps->new (radix => $r)"
40 Create and return a new sequence object.
41
42 Random Access
43 "$value = $seq->ith($i)"
44 Return the number of reverse-add steps required to reach a
45 palindrome.
46
47 "$bool = $seq->pred($value)"
48 Return true if $value occurs in the sequence, which simply means
49 "$value >= 0" since any count of steps is possible, or "$value==-1"
50 for infinite.
51
53 Math::NumSeq, Math::NumSeq::ReverseAdd, Math::NumSeq::CollatzSteps,
54 Math::NumSeq::JugglerSteps
55
57 <http://user42.tuxfamily.org/math-numseq/index.html>
58
60 Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
61
62 Math-NumSeq is free software; you can redistribute it and/or modify it
63 under the terms of the GNU General Public License as published by the
64 Free Software Foundation; either version 3, or (at your option) any
65 later version.
66
67 Math-NumSeq is distributed in the hope that it will be useful, but
68 WITHOUT ANY WARRANTY; without even the implied warranty of
69 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
70 General Public License for more details.
71
72 You should have received a copy of the GNU General Public License along
73 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
74
75
76
77perl v5.36.0 2023-01-20 Math::NumSeq::ReverseAddSteps(3)