OFFSET
1,3
COMMENTS
To extend the sequence S with a new term a(n), we always try to subtract from a(n-1) the last absolute difference D between two digits that we must consider. If a(n) is already in S, we add D to a(n-1) instead of subtracting, even if this new a(n) is already in S.
Note that a(n) is sometimes < a(n-1).
LINKS
Carole Dubois, Table of n, a(n) for n = 1..5002
EXAMPLE
After a(10) = 9, we cannot extend S with a(11) < 17 as the difference between a(10) and a(11) cannot be < 8, this 8 being the difference between 9 and the first digit of a(11);
After a(11) = 17, we are driven by the next absolute difference between digits, which is 6 (the difference between the 1 and the 7 of 17). As a(11) - 6 = 11 and this 11 is not yet in S, we keep this 11 as a(12);
After a(12) = 11, the next absolute difference between two digits that we must consider is 6 again (this 6 comes from the difference between the 7 of 17 and the first 1 of 11); but as a(12) = 11 and 11 - 6 is 5, we won't accept this 5 for a(13) as 5 is already in S; we then add 6 to a(12) instead of subtracting, and we produce another 17 in S (this is allowed as we are adding an absolute difference, not subtracting). So a(13) is now 17;
After a(13) = 17, the next absolute difference between two digits that we must consider is 0 (this 0 comes from the difference between the two 1s of 11); so a(14) = 17; etc.
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Jun 11 2020
STATUS
approved