1Math::NumSeq::HofstadteUrsFeirguCroen(t3r)ibuted Perl DoMcautmhe:n:tNautmiSoenq::HofstadterFigure(3)
2
3
4
6 Math::NumSeq::HofstadterFigure -- sequence excludes its own first
7 differences
8
10 use Math::NumSeq::HofstadterFigure;
11 my $seq = Math::NumSeq::HofstadterFigure->new;
12 my ($i, $value) = $seq->next;
13
15 This is Douglas Hofstadter's "figure" sequence which comprises all
16 integers except those which are differences between its own successive
17 values,
18
19 1, 3, 7, 12, 18, 26, 35, 45, 56, 69, 83, 98, ...
20
21 So for example at value=1 the next cannot be 2 because the difference
22 2-1=1 is already in the sequence, so value=3 with difference 3-1=2 is
23 next. Then the next cannot be 4 since 4-3=1 is already in the
24 sequences, and likewise 5-3=2 and 6-3=3, so the next is value=7 with
25 7-3=4 not already in the sequence.
26
27 The effect is that the sequence increments by 1,2,3,4, etc but
28 excluding values of the sequence itself. This makes it close to the
29 Triangular numbers i*(i+1)/2, but incrementing by a little extra at the
30 places it skips its own values.
31
32 Start Value
33 The optional "start => $value" can give the first value for the
34 sequence, instead of the default 1. For example starting at 2
35
36 2, 3, 7, 12, 18, 26, 35, 45, 56, ...
37
38 or starting at 5
39
40 5, 6, 8, 11, 15, 22, 31, 41, 53, 66, ...
41
42 The differences are still the values not in the sequence, so for
43 example starting at 5 means the differences are 1, 2, 3, 4 before
44 skipping 5 and 6.
45
46 In general the effect is to push the first skip up a bit, but still
47 settles down to grow roughly like the triangular numbers.
48
49 The start > must be 1 or more. If the start was 0 then the first value
50 and first difference would always be the same, contradicting the
51 conditions for the sequence.
52
54 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
55 classes.
56
57 "$seq = Math::NumSeq::HofstadterFigure->new ()"
58 "$seq = Math::NumSeq::HofstadterFigure->new (start => $value)"
59 Create and return a new sequence object.
60
62 Math::NumSeq, Math::NumSeq::Kolakoski
63
65 <http://user42.tuxfamily.org/math-numseq/index.html>
66
68 Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019 Kevin Ryde
69
70 Math-NumSeq is free software; you can redistribute it and/or modify it
71 under the terms of the GNU General Public License as published by the
72 Free Software Foundation; either version 3, or (at your option) any
73 later version.
74
75 Math-NumSeq is distributed in the hope that it will be useful, but
76 WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
78 General Public License for more details.
79
80 You should have received a copy of the GNU General Public License along
81 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
82
83
84
85perl v5.34.0 2021-07-22 Math::NumSeq::HofstadterFigure(3)