NAME

Math::NumSeq::MathImageHofstadterDiff -- sequence excludes its own first differences

SYNOPSIS

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

DESCRIPTION

This is Douglas Hofstadter's R/S sequence which comprises all integers except those which are the differences between its own successive values,

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

So for example at value=1 the next cannot be 2 because the difference 2-1=1 is already in the sequence, so value=3 with difference 3-1=2 is next. Then the next cannot be 4 since 4-3=1 is already in the sequences, and likewise 5-3=2 and 6-3=3, so the next is value=7 with 7-3=4 not already in the sequence.

The effect is that the sequence increments by 1,2,3,4, etc excluding values of the sequence itself. This makes it close to the Triangular numbers i*(i+1)/2, but incrementing by a little extra at the places it skips its own values.

FUNCTIONS

$seq = Math::NumSeq::MathImageHofstadterDiff->new ()

Create and return a new sequence object.

SEE ALSO

Math::NumSeq, Math::NumSeq::Kolakoski