OFFSET
1,10
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
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
KEYWORD
AUTHOR
David A. Corneth, Apr 23 2021
STATUS
approved