login
When a(n) is odd, a(n) is the number of even digits present so far in the sequence, a(n) included.
6

%I #9 Nov 15 2020 12:55:33

%S 0,1,2,4,3,6,8,5,10,12,7,14,16,9,18,20,22,24,26,28,21,30,23,32,25,34,

%T 27,36,29,38,40,42,44,46,48,41,50,43,52,45,54,47,56,49,58,60,62,64,66,

%U 68,61,70,63,72,65,74,67,76,69,78,80,82,84,86,88,81,90,83,92,85,94,87,96,89,98,100,102,104

%N When a(n) is odd, a(n) is the number of even digits present so far in the sequence, a(n) included.

%C The even nonnegative integers are present in their natural order. Some odd natural integers will never appear (11 for instance).

%e The first odd term is a(2) = 1 and there is indeed 1 even digit so far in the sequence (0);

%e The next odd term is a(5) = 3 and there are now 3 even digits so far (0, 2 and 4);

%e The next odd term is a(8) = 5 and there are now 5 even digits so far (0, 2, 4, 6 and 8);

%e ...

%e The term a(21) = 21 and there are indeed 21 even digits in the sequence so far (0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 2, 0, 2, 2, 2, 4, 2, 6, 2, 8, 2); etc.

%t Block[{a = {0}, c = 1}, Do[Block[{k = 1, s}, While[If[OddQ[k], Nand[FreeQ[a, k], k == c + Set[s, Total@DigitCount[k, 10, {0, 2, 4, 6, 8}]]], ! FreeQ[a, k]], k++]; If[OddQ[k], c += s, c += Total@ DigitCount[k, 10, {0, 2, 4, 6, 8}]]; AppendTo[a, k]], {i, 77}]; a] (* _Michael De Vlieger_, Nov 06 2020 *)

%Y Cf. A338741, A338742, A338744, A338745, A338746 (variants on the same idea), A196563.

%K base,nonn

%O 1,3

%A _Eric Angelini_ and _Carole Dubois_, Nov 06 2020