login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A343644
a(n) is the sum of the number of occurrences of each digit of n up to and including that digit.
1
1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 7, 7, 8, 9, 10, 11, 12, 13, 14, 5, 17, 11, 10, 11, 12, 13, 14, 15, 16, 7, 19, 20, 15, 13, 14, 15, 16, 17, 18, 9, 21, 22, 23, 19, 16, 17, 18, 19, 20, 11, 23, 24, 25, 26, 23, 19, 20, 21, 22, 13, 25, 26, 27, 28, 29, 27, 22, 23, 24, 15, 27
OFFSET
1,10
LINKS
EXAMPLE
a(10) = 3 as the digit 1 is the second digit 1 and the digit 0 is the first digit 0 giving 2+1.
a(22) is 11 as the digits of 22 are 2 and 2. Before 22 the digit 2 occurred four times, in 2, 12, 20 in 21. The first 2 in 22 is the fifth in total. The second 2 in 22 is the sixth 2 in total giving 5 + 6.
MATHEMATICA
Array[Sum[Count[Flatten@Join[IntegerDigits/@Range[#-1], a[[;; k]]], a[[k]]], {k, Length[a=IntegerDigits@#]}]&, 100] (* Giorgos Kalogeropoulos, Apr 23 2021 *)
PROG
(PARI) first(n) = my(v=vector(10), res=vector(n)); for(i=1, n, c=0; d=digits(i); for(i=1, #d, v[d[i]+1]++; c+=v[d[i]+1]); res[i]=c); res
(Python)
def aupto(limit):
f, alst = [0 for i in range(10)], []
for n in range(1, limit+1):
s = 0
for d in list(map(int, str(n))): f[d] += 1; s += f[d]
alst.append(s)
return alst
print(aupto(71)) # Michael S. Branicky, Apr 23 2021
CROSSREFS
Cf. A343645.
Sequence in context: A325894 A370517 A176269 * A081522 A020764 A010625
KEYWORD
nonn,easy,base,look
AUTHOR
David A. Corneth, Apr 23 2021
STATUS
approved