OFFSET
1,2
COMMENTS
When an iteration reproduces a term already in the sequence, we cancel this iteration and restart the sequence from there with the smallest integer not yet present in the sequence.
EXAMPLE
As a(1) = 1, we get a(2) = 2 by adding the odd digit 1 to a(1);
as a(2) = 2, we get a(3) = 0 by subtracting the even digit 2 from a(2);
as a(3) = 0, we stop to iterate (0 would produce 0, already in the sequence) and restart the sequence with a(4) = 3, the smallest integer not present;
as a(4) = 3, we get a(5) = 6 by adding the odd digit 3 to a(4);
as a(5) = 6, we stop to iterate (6-6 produces 0, already in the sequence) and restart the sequence with a(6) = 4, the smallest integer not present;
as a(6) = 4, we stop to iterate (4-4 produces 0, already in the sequence) and restart the sequence with a(7) = 5, the smallest integer not present;
as a(7) = 5, we get a(8) = 10 by adding the odd digit 5 to a(7);
as a(8) = 10, we get a(9) = 11 by adding the odd digit 1 to a(8);
as a(9) = 11, we get a(10) = 13 by adding the odd digits 1 and 1 to a(9); etc.
MATHEMATICA
Nest[Append[#1, If[FreeQ[#1, #2], #2, Block[{k = 3}, While[! FreeQ[#1, k], k++]; k]] & @@ {#1, #1[[-1]] + Total@ Select[#2, OddQ] - Total@ Select[#2, EvenQ]} & @@ {#, IntegerDigits@ #[[-1]]}] &, {1}, 77] (* Michael De Vlieger, Dec 24 2019 *)
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Dec 24 2019
STATUS
approved