A277635 Number of 7's appearing in the sequence of consecutive natural numbers from 1 to A007908(n), where A007908 = (1, 12, 123, 1234, ...).
0, 1, 22, 343, 4664, 58985, 713307, 8367637, 96022049
Offset: 1
Examples
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. 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.
Links
- Puzzling Stack Exchange, How many sevens?
- M. F. Hasler, Digits d in 0 through 123...n, OEIS Wiki, Nov. 2016.
Crossrefs
Programs
-
Mathematica
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 *)
-
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
-
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
Comments