login
Numbers with equal number of even and odd digits such that the sum a(n) + a(n+1) has an equal number of even and odd digits too.
1

%I #12 Dec 18 2020 04:17:27

%S 10,1090,12,18,14,16,25,27,23,29,21,49,32,38,34,36,45,47,43,1007,54,

%T 1009,41,1029,52,1018,56,1005,58,1003,67,1014,69,1001,89,1120,81,1021,

%U 83,1023,85,1041,61,1043,63,1027,65,1016,74,1030,70,1032,72,1034,90,1010,92,1012,78,1050,50,1052,76,1070,30

%N Numbers with equal number of even and odd digits such that the sum a(n) + a(n+1) has an equal number of even and odd digits too.

%C Lexicographically earliest sequence of distinct positive terms with this property.

%C Numbers with an odd digit length cannot be in this sequence.

%e a(1) + a(2) = 10 + 1090 = 1100 (which has an equal number of even and odd digits);

%e a(2) + a(3) = 1090 + 12 = 1102 (idem);

%e a(3) + a(4) = 12 + 18 = 30 (idem);

%e a(4) + a(5) = 18 + 14 = 32 (idem); etc.

%o (Python)

%o def cond(i):

%o stri = str(i)

%o se = sum(1 for d in stri if d in "02468")

%o so = sum(1 for d in stri if d in "13579")

%o return se == so

%o def aupto(nn):

%o alst, used = [0], set()

%o for n in range(1, nn+1):

%o an = 10

%o while True:

%o while an in used: an += 1

%o if cond(an) and cond(an + alst[-1]):

%o alst.append(an); used.add(an); break

%o an += 1

%o return alst[1:] # use alst[n] for a(n)

%o print(aupto(56)) # _Michael S. Branicky_, Dec 14 2020

%Y Cf. A339715 (same idea, replacing addition by multiplication), A227870 (numbers with equal number of even and odd digits).

%K base,nonn

%O 1,1

%A _Eric Angelini_ and _Carole Dubois_, Dec 14 2020