login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Lexicographically earliest sequence of distinct terms such that a(n+1) = a(n) + the largest odd digit of a(n), starting with a(n) = 1. If this addition is impossible, or if it leads to a term already in the sequence, restart the sequence from there with the smallest unused integer.
1

%I #18 Jan 13 2020 20:59:38

%S 1,2,3,6,4,5,10,11,12,13,16,17,24,7,14,15,20,8,9,18,19,28,21,22,23,26,

%T 25,30,33,36,39,48,27,34,37,44,29,38,41,42,31,32,35,40,43,46,45,50,55,

%U 60,47,54,59,68,49,58,63,66,51,56,61,62,52,57,64,53,65,70,77,84,67,74,81,82,69,78,85,90,99,108,109

%N Lexicographically earliest sequence of distinct terms such that a(n+1) = a(n) + the largest odd digit of a(n), starting with a(n) = 1. If this addition is impossible, or if it leads to a term already in the sequence, restart the sequence from there with the smallest unused integer.

%C This sequence is a permutation of the positive integers.

%H Carole Dubois, <a href="/A331117/b331117.txt">Table of n, a(n) for n = 1..5000</a>

%e a(1) = 1

%e a(2) = a(1) + 1 = 2;

%e as a(2) = 2 has no odd digit, we restart the sequence with a(3) = 3;

%e a(4) = a(3) + 3 = 6;

%e as a(4) = 6 has no odd digit, we restart the sequence with a(5) = 4;

%e as a(5) = 4 has no odd digit, we restart the sequence with a(6) = 5;

%e a(6) = a(5) + 5 = 10;

%e a(7) = a(6) + 1 = 11;

%e a(8) = a(7) + 1 = 12;

%e a(9) = a(8) + 1 = 13;

%e a(10) = a(9) + 3 = 16; etc.

%t Nest[Append[#1, If[FreeQ[#1, #2], #2, Block[{k = 2}, While[! FreeQ[#1, k], k++]; k]] ] & @@ {#1, If[Length@ #2 > 0, #1[[-1]] + #2[[-1]], 1]} & @@ {#, Select[Union@ IntegerDigits[#[[-1]] ], OddQ]} &, {1}, 80] (* _Michael De Vlieger_, Jan 11 2020 *)

%K base,nonn

%O 1,2

%A _Eric Angelini_ and _Carole Dubois_, Jan 10 2020