login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A227870 Numbers with equal number of even and odd digits. 11

%I #30 Jun 23 2022 20:32:14

%S 10,12,14,16,18,21,23,25,27,29,30,32,34,36,38,41,43,45,47,49,50,52,54,

%T 56,58,61,63,65,67,69,70,72,74,76,78,81,83,85,87,89,90,92,94,96,98,

%U 1001,1003,1005,1007,1009,1010,1012,1014,1016,1018,1021,1023,1025

%N Numbers with equal number of even and odd digits.

%C Numbers with an odd digit length cannot be in this sequence. - _Alonso del Arte_, Nov 02 2013

%H Amiram Eldar, <a href="/A227870/b227870.txt">Table of n, a(n) for n = 1..10000</a>

%e 1009 has 2 even digits (00) and 2 odd digits (19) and so is in the sequence.

%t Select[Range[1025], (d = Differences[Tally[Mod[IntegerDigits[#], 2]]]) != {} && d[[1, 2]] == 0 &] (* _Amiram Eldar_, Oct 01 2020 *)

%o (JavaScript)

%o for (i = 1; i < 5000; i++) {

%o s = i.toString();

%o odds = 0; evens = 0;

%o for (j = 0; j < s.length; j++) if (s.charAt(j)%2 == 0) evens++; else odds++;

%o if (odds == evens) document.write(i + ", ");

%o }

%o (PARI) isok(m) = my(d=digits(m)); #select(x->(x%2), d) == #select(x->!(x%2), d); \\ _Michel Marcus_, Oct 01 2020

%o (Python)

%o def ok(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, an = [None], 0

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

%o while len(alst) < nn+1:

%o if ok(an): alst.append(an)

%o an += 1

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

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

%Y Cf. A030141, A031443.

%K nonn,base,easy

%O 1,1

%A _Jon Perry_, Nov 02 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)