[go: up one dir, main page]

login
Lexicographically earliest sequence S of distinct nonnegative terms such that the sum of the last k digits of S is even, k being the leftmost digit of a(n).
0

%I #14 May 11 2022 02:43:02

%S 0,2,20,4,6,21,3,8,22,5,7,40,9,30,23,31,50,24,25,32,26,27,33,51,70,28,

%T 29,34,35,41,36,37,42,60,43,38,39,44,61,52,45,71,53,72,46,47,54,48,49,

%U 55,56,57,58,59,62,63,64,73,74,75,65,300,66,80,67,76,68,69,90,81,77,91,78,79,82,83,301,302,84

%N Lexicographically earliest sequence S of distinct nonnegative terms such that the sum of the last k digits of S is even, k being the leftmost digit of a(n).

%e a(1) = 0, k = 0, and the sum 0 is even;

%e a(2) = 2, k = 2, and the sum 0 + 2 (= 2) is even;

%e a(3) = 20, k = 2, and the sum 2 + 2 (= 4) is even;

%e a(4) = 4, k = 4, and the sum 2 + 2 + 0 + 4 (= 8) is even;

%e a(5) = 6, k = 6, and the sum 0 + 2 + 2 + 0 + 4 + 6 (= 14) is even;

%e a(6) = 21, k = 2, and the sum 6 + 2 (= 8) is even; etc.

%t a[1]=0;a[n_]:=a[n]=Block[{k=1},While[(p=First@IntegerDigits@k;p>Length[s=Flatten[IntegerDigits/@Join[Array[a,n-1],{p}]]])||MemberQ[Array[a,n-1],k]||!EvenQ@Total[s[[-p;;]]],k++];k];Array[a,79] (* _Giorgos Kalogeropoulos_, May 09 2022 *)

%Y Cf. A344540.

%K nonn,base

%O 1,2

%A _Eric Angelini_ and _Carole Dubois_, May 30 2021