Math::N...rFigure(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Math::NumSeq::HofstadterFigure β€” bestie, it's a sequence that literally refuses to contain its own first differences. Like, it excludes them. Iconic behavior honestly.

This page lives in the User Contributed Perl Documentation section of your manual, btw 🫢


✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so this is Douglas Hofstadter's "figure" sequence, and the whole vibe is: it's every single integer except the ones that happen to be differences between its own successive values. She's exclusionary, your honor πŸ’…

1, 3, 7, 12, 18, 26, 35, 45, 56, 69, 83, 98, ...

Not me explaining it like a study group bestie, but fr fr: say you're at value=1. The next one cannot be 2, because the difference 2-1=1 is already chillin' inside the sequence. So we go to value=3, where the difference 3-1=2 is not already there. Slay.

Then the next one can't be 4, since 4-3=1 is already in the sequence. Same energy for 5-3=2 and 6-3=3 β€” both already taken. So the next value is 7, because 7-3=4 isn't already in the sequence. Ate.

The effect? The sequence increments by 1, 2, 3, 4, etc but it skips over values of the sequence itself. So it's lowkey close to the Triangular numbers i*(i+1)/2, except it bumps up by a little extra at the exact spots where it skips its own values. Main character behavior only πŸ’œ

🌸 Start Value 🌸

The optional start => $value lets you pick the first value for the sequence instead of the default 1. Like, starting at 2:

2, 3, 7, 12, 18, 26, 35, 45, 56, ...

or starting at 5:

5, 6, 8, 11, 15, 22, 31, 41, 53, 66, ...

The differences are still the values that aren't in the sequence, so for example starting at 5 means the differences are 1, 2, 3, 4 before it skips 5 and 6.

In general the effect is to push the first skip up a bit, but it still settles down to grow roughly like the triangular numbers. She finds her footing, okay? 🧚

⚠️ The start must be 1 or more. If the start was 0, then the first value and the first difference would always be the same thing, which straight-up contradicts the conditions for the sequence. So like... don't. 😭

πŸŽ€ FUNCTIONS πŸŽ€

See "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all sequence classes.

  • $seq = Math::NumSeq::HofstadterFigure->new ()
  • $seq = Math::NumSeq::HofstadterFigure->new (start => $value)

Create and return a new sequence object. That's it, that's the function bestie ✨


πŸ’… SEE ALSO πŸ’…

  • Math::NumSeq
  • Math::NumSeq::Kolakoski

🌈 HOME PAGE 🌈

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


πŸ‘‘ LICENSE πŸ‘‘

Copyright 2010, 2011, 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/>.


k bye bestie, that was Math::NumSeq::HofstadterFigure(3) from perl v5.42.0, dated 2025-07-25 β€” go forth and sequence responsibly, mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from