A358854 Number of even digits necessary to write all the numbers from 0 up to n.
1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 12, 13, 15, 16, 18, 19, 21, 22, 24, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 52, 53, 55, 56, 58, 59, 61, 62, 64, 65, 66, 66, 67, 67, 68, 68
Offset: 0
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..20000
- United Kingdom Mathematics Trust, 2016/17 British Mathematical Olympiad Round 1, Problem 1
- Index to sequences related to Olympiads.
Programs
-
Maple
a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+ nops(select(x-> x::even, convert(n, base, 10)))) end: seq(a(n), n=0..100); # Alois P. Heinz, Feb 19 2023
-
Mathematica
Accumulate[Table[Count[IntegerDigits[n], ?EvenQ], {n, 0, 100}]] (* _Amiram Eldar, Dec 03 2022 *)
-
Python
from itertools import accumulate, count, islice def A196563(n): return sum(1 for d in str(n) if d in "02468") def agen(): yield from accumulate(A196563(n) for n in count(0)) print(list(islice(agen(), 76))) # Michael S. Branicky, Dec 03 2022
Comments