A277832 Number of '2' digits in the set of all numbers from 0 to A014824(n) = Sum_{i=1..n} i*10^(n-i) = (0, 1, 12, 123, 1234, 12345, ...).
0, 0, 2, 27, 389, 5121, 63553, 758985, 8824417, 100589849, 1129355281, 12528120713, 137626886149, 1499725651622, 16231824417465, 174663923187008, 1870096021993551, 19935528121170094, 211700960224046637, 2240466392363923180, 23639231824873799723
Offset: 0
Examples
For n=2 are counted the two '2's in { 2, 12 }.
Links
- David A. Corneth, Table of n, a(n) for n = 0..998
Programs
-
Mathematica
Array[Total@ DigitCount[Range[Sum[10^i - 1, {i, #}]/9], 10, 2] &, 7] (* Michael De Vlieger, Dec 31 2020 *)
-
PARI
print1(c=N=0);for(n=1,8,print1(","c+=sum(k=N+1,N=N*10+n,#select(d->d==2,digits(k)))))
-
PARI
A277832(n)=if(n<3,(n==2)*2, n<13,A277833(n)+4*10^(n-3), error("n > 12 not yet implemented")) \\ M. F. Hasler, Nov 02 2016, edited Dec 28 2020
-
PARI
a(n) = {if(n == 0, return(0)); n = (10^(n+1)\9-n)\9; f(n, 2) } f(n, {c = 2}) = { my(d = digits(n), res = 0); for(i = 1, #d - 1, res += d[i] * (#d - i)*10^(#d - i - 1); if(d[i]==c, res+=(n % (10^(#d - i)) + 1); ); if(d[i] > c, res+=(10^(#d - i)) ); ); if(d[#d] >= c, res++); res } \\ David A. Corneth, Dec 31 2020
Formula
Extensions
More terms from Lars Blomberg, Nov 05 2016
Removed incorrect b-file. - David A. Corneth, Dec 31 2020