login
Number of 7's appearing in the sequence of consecutive natural numbers from 1 to A007908(n), where A007908 = (1, 12, 123, 1234, ...).
11

%I #46 Jan 01 2021 12:04:41

%S 0,1,22,343,4664,58985,713307,8367637,96022049

%N Number of 7's appearing in the sequence of consecutive natural numbers from 1 to A007908(n), where A007908 = (1, 12, 123, 1234, ...).

%C First 6 terms are the same as in A083449, also see A272525. [See the OEIS wiki page for more details. - _M. F. Hasler_, Dec 29 2020]

%C a(n) gives the number of times the digit 7 occurs in all terms of A000027 in the interval [A000027(1), A007908(n)]. - _Felix Fröhlich_, Oct 28 2016

%C The sequence was initially defined only up to n = 9 and then extended using A007908 = concat(1..n); see A277837 for the extension using A014824 (a(n) = 10 a(n-1) + n) leading to a smoother growth, in particular at powers of 10. - _M. F. Hasler_, Nov 01 2016, edited Dec 29 2020

%H Puzzling Stack Exchange, <a href="http://puzzling.stackexchange.com/questions/42029/how-manysevens">How many sevens?</a>

%H M. F. Hasler, <a href="https://oeis.org/wiki/User_talk:M._F._Hasler/Digits_d_in_0_through_123...n">Digits d in 0 through 123...n</a>, OEIS Wiki, Nov. 2016.

%e 22 is the third term of the sequence because there are 22 occurrences of the digit '7' contained in numbers within the range of 1 to 123.

%e 96022049 is the 9th term of the sequence because there are 96022049 occurrences of the digit '7' contained in numbers within the range of 1 to 123456789.

%t Table[a[n] = Count[Flatten@ Map[IntegerDigits, Range@ FromDigits@ Range@ n], k_ /; k == 8]; Print@ a@ n; an = a[n]; an, {n, 0, 9}] (* _Michael De Vlieger_, Oct 30 2016 *)

%o (PARI) print1(c=0);N=1;for(n=2,8,print1(","c+=sum(k=N+1,N=eval(Str(N,n)),#select(d->d==7,digits(k))))) \\ For illustration; more efficient code below. - _M. F. Hasler_, Oct 31 2016

%o (PARI) A277635(n, m=7)=if(n>m,A277635(n, m+1)+(m+2)*10^(n-m-1),A277830(n)-(m>n)) \\ Valid only for n <= 9. - _M. F. Hasler_, Nov 02 2016

%Y Cf. A083449, A272525, A014824.

%Y Cf. A277830 - A277838 and A277849: analog for digits 0 .. 9, but based on A014824 instead of A083449.

%K nonn,base

%O 1,3

%A _Alexander R. Povolotsky_, Oct 24 2016