OFFSET
1,2
COMMENTS
Start with a(1) = 1 and a(2) = 2; read the sequence digit by digit starting from the left:
when the read digit is smaller than the next one, multiply by 2 the last integer of the sequence and extend it with the result;
when the read digit is bigger than the next one, subtract 1 from the last integer of the sequence and extend it with the result;
when both digits are equal, extend the sequence with the smallest integer not present so far.
LINKS
Jean-Marc Falcoz, Table of n, a(n) for n = 1..10002
EXAMPLE
As the only digit of a(1) = 1 is smaller than 2 (the next digit), we extend the sequence with 4 (that is, 2 times 2);
as the only digit of a(2) = 2 is smaller than 4 (the next digit), we extend the sequence with 8 (that is, 2 times 4);
as the only digit of a(3) = 4 is smaller than 8 (the next digit), we extend the sequence with 16 (that is, 2 times 8);
as the only digit of a(4) = 8 is bigger than 1 (the next digit), we extend the sequence with 15 (that is, 16 minus 1);
as the first digit of a(5) = 1 is smaller than 6 (the next digit), we extend the sequence with 30 (that is, 2 times 15);
as the last digit of a(5) = 6 is bigger than 1 (the next digit), we extend the sequence with 29 (that is, 30 minus 1);
...
as the first digit of a(12) = 1 is equal to 1 (the next digit), we extend the sequence with 3 (this is the smallest integer not yet present in the sequence and is written after a(23) = 1777);
etc.
CROSSREFS
KEYWORD
AUTHOR
Eric Angelini and Jean-Marc Falcoz, Jul 12 2018
STATUS
approved