login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A227870 Numbers with equal number of even and odd digits. 6
10, 12, 14, 16, 18, 21, 23, 25, 27, 29, 30, 32, 34, 36, 38, 41, 43, 45, 47, 49, 50, 52, 54, 56, 58, 61, 63, 65, 67, 69, 70, 72, 74, 76, 78, 81, 83, 85, 87, 89, 90, 92, 94, 96, 98, 1001, 1003, 1005, 1007, 1009, 1010, 1012, 1014, 1016, 1018, 1021, 1023, 1025 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

Numbers with an odd digit length cannot be in this sequence. - Alonso del Arte, Nov 02 2013

LINKS

Amiram Eldar, Table of n, a(n) for n = 1..10000

EXAMPLE

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

MATHEMATICA

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

PROG

(Javacript)

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

s = i.toString();

odds = 0; evens = 0;

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

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

}

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

(Python)

def ok(i):

  stri = str(i)

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

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

  return se == so

def aupto(nn):

  alst, an = [None], 0

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

    while len(alst) < nn+1:

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

      an += 1

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

print(aupto(58))  # Michael S. Branicky, Dec 14 2020

CROSSREFS

Cf. A030141, A031443.

Sequence in context: A180157 A309539 A273492 * A007958 A179083 A092132

Adjacent sequences:  A227867 A227868 A227869 * A227871 A227872 A227873

KEYWORD

nonn,base,easy

AUTHOR

Jon Perry, Nov 02 2013

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 14 19:38 EDT 2021. Contains 343902 sequences. (Running on oeis4.)