cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 197 results. Next

A267939 Number x = concat(MSD(x),b), where MSD = A000030 stands for Most Significant Digit, such that MSD(x)*b is equal to the reverse of x.

Original entry on oeis.org

351, 621, 886, 920781, 3524751, 338752611, 35247524751, 920780120781, 920879219781, 3387524752611, 3526124738751, 338738752612611, 352475247524751, 33875247524752611, 35247387526124751, 35261247524738751, 920780120780120781, 920780219879120781, 920879120780219781, 920879219879219781
Offset: 1

Views

Author

Paolo P. Lava, Jan 22 2016

Keywords

Comments

If we consider numbers x = concat(a,b), where a has two digits, such that a*b is equal to the reverse of x, the first terms are 425322, 44235301, 119910901, ...
Terms of the form 3(5247)*51, i.e. 351, 3524751, 35247524751, ..., form an infinite subsequence. - Robert Israel, Jan 28 2016
Other infinite sequences of terms include 92078(012078)*1 and 33875(2475)*2611. - Robert Israel, Jan 31 2016

Examples

			3*51 = 153;
6*21 = 126;
3*524751 = 1574253.
		

Crossrefs

Programs

  • Maple
    T:=proc(w) local x, y, z; x:=w; y:=0;
    for z from 1 to ilog10(x)+1 do y:=10*y+(x mod 10); x:=trunc(x/10); od; y; end:
    P:=proc(q) local a,b,n; for n from 1 to q do a:=n mod 10; b:=trunc(n/10^ilog10(n));
    if (a=1 and b>1) or (a=6 and (b=2 or b=4 or b=6 or b=8)) or (b=5 and (a=3 or a=5 or a=7 or a=9)) then
    if T(n)=b*(n mod 10^ilog10(n)) then print(n); fi; fi; od; end: P(10^10);
    # alternative:
    N:= 20: # to get all terms with at most N digits.
    extend:= proc(d,psol,eqs)
      local peqs, cvars, bvars, ncs, res,T, cs, ceqs, sol, svals;
      peqs:= subs(psol, eqs);
      cvars,bvars:= selectremove(t -> op(0,t) = 'c',indets(peqs));
      ncs:= nops(cvars);
      res:= NULL;
      if ncs >= 1 then
        T:= combinat:-cartprod([[$0..d-1]$ncs]);
        while not T[finished] do
          cs:= T[nextvalue]();
          cs:= seq(cvars[i]=cs[i],i=1..ncs);
          ceqs:= subs(cs,peqs);
          sol:= solve(ceqs,bvars); svals:= map(rhs,sol);
          if indets(svals) <> {} then error("Oops: %1",svals) fi;
          if svals::set(nonnegint) and max(svals) <= 9 then
            res:= res, [op(psol), cs, op(sol)];
          fi
        od
      else
        sol:= solve(peqs,bvars);
        svals:= map(rhs,sol);
        if indets(svals) <> {} then error("Oops: %1",svals) fi;
        if svals::set(nonnegint) and max(svals) <= 9 then
            res:= [op(psol), op(sol)];
        fi
      fi;
      [res]
    end proc:
    G:= proc(d,n)
         local eqs, i, rs, b0s;
         eqs:= [d*b[0] - d - 10*c[0],
                seq(d*b[i]+c[i-1] - b[n-i] - 10*c[i], i=1..n-2),
                d*b[n-1] + c[n-2] - b[1] - 10*b[0]];
         b0s:= [msolve(eqs[1] mod 10,10)];
         rs:= select(t -> (map(rhs,t))::set(nonnegint),
             map(t -> t union solve(eval(eqs[1],t),{c[0]}),b0s));
         for i from 1 to floor(n/2) do
            rs:= map(s -> op(extend(d,s,{eqs[i+1],eqs[-i]})), rs);
         od;
         sort(map(s -> d*10^n + subs(s, add(10^i*b[i],i=0..n-1)), rs));
    end proc:
    A:= NULL;
    for n from 2 to N-1 do
      for d from 3 to 9 do
        res:= G(d,n);
        if res <> [] then
          A:= A, op(res);
        fi
      od
    od:
    A; # Robert Israel, Feb 01 2016
  • Mathematica
    Select[Range@ 4000000, First[#] FromDigits@ Rest@ # == FromDigits@ Reverse@ # &@ IntegerDigits@ # &] (* Michael De Vlieger, Jan 29 2016 *)

Extensions

a(7) to a(20) from Robert Israel, Feb 01 2016

A031298 Triangle T(n,k): write n in base 10, reverse order of digits.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 0
Offset: 0

Views

Author

Keywords

Comments

The length of n-th row is given in A055642(n). - Reinhard Zumkeller, Jul 04 2012
According to the formula for T(n,1), columns are numbered starting with 1. One might also number columns starting with the offset 0, as to have the coefficient of 10^k in column k. - M. F. Hasler, Jul 21 2013

Crossrefs

Cf. A030308, A030341, A030386, A031235, A030567, A031007, A031045, A031087 for the base-2 to base-9 analogs.

Programs

  • Haskell
    a031298 n k = a031298_tabf !! n !! k
    a031298_row n = a031298_tabf !! n
    a031298_tabf = iterate succ [0] where
       succ []     = [1]
       succ (9:ds) = 0 : succ ds
       succ (d:ds) = (d + 1) : ds
    -- Reinhard Zumkeller, Jul 04 2012
    
  • Mathematica
    Table[Reverse[IntegerDigits[n]],{n,0,50}]//Flatten (* Harvey P. Dale, Mar 07 2023 *)
  • PARI
    T(n,k)=n\10^(k-1)%10 \\ M. F. Hasler, Jul 21 2013

Formula

T(n,1) = A010879(n); T(n,A055642(n)) = A000030(n). - Reinhard Zumkeller, Jul 04 2012

Extensions

Initial 0 and better name by Philippe Deléham, Oct 20 2011
Edited by M. F. Hasler, Jul 21 2013

A037123 a(n) = a(n-1) + sum of digits of n.

Original entry on oeis.org

0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 46, 48, 51, 55, 60, 66, 73, 81, 90, 100, 102, 105, 109, 114, 120, 127, 135, 144, 154, 165, 168, 172, 177, 183, 190, 198, 207, 217, 228, 240, 244, 249, 255, 262, 270, 279, 289, 300, 312, 325, 330, 336, 343, 351, 360, 370, 381
Offset: 0

Views

Author

Vasiliy Danilov (danilovv(AT)usa.net), Jun 15 1998

Keywords

Comments

Sum of digits of A007908(n). - Franz Vrabec, Oct 22 2007
Also digital sum of A138793(n) for n > 0. - Bruno Berselli, May 27 2011
Sum of the digital sum of i for i from 0 to n. - N. J. A. Sloane, Nov 13 2013

References

  • N. Agronomof, Sobre una función numérica, Revista Mat. Hispano-Americana 1 (1926), 267-269.
  • Maurice d'Ocagne, Sur certaines sommations arithmétiques, J. Sciencias Mathematicas e Astronomicas 7 (1886), 117-128.

Crossrefs

Cf. also A074784, A231688, A231689.
Partial sums of A007953.

Programs

  • Magma
    [ n eq 0 select 0 else &+[&+Intseq(k): k in [0..n]]: n in [0..56] ];  // Bruno Berselli, May 27 2011
  • Maple
    # From N. J. A. Sloane, Nov 13 2013:
    digsum:=proc(n,B) local a; a := convert(n, base, B):
    add(a[i], i=1..nops(a)): end;
    f:=proc(n,k,B) global digsum; local i;
    add( digsum(i,B)^k,i=0..n); end;
    lprint([seq(digsum(n,10),n=0..100)]); # A007953
    lprint([seq(f(n,1,10),n=0..100)]); #A037123
    lprint([seq(f(n,2,10),n=0..100)]); #A074784
    lprint([seq(f(n,3,10),n=0..100)]); #A231688
    lprint([seq(f(n,4,10),n=0..100)]); #A231689
  • Mathematica
    Table[Plus@@Flatten[IntegerDigits[Range[n]]], {n, 0, 200}] (* Enrique Pérez Herrero, Oct 12 2015 *)
    a[0] = 0; a[n_] := a[n - 1] + Plus @@ IntegerDigits@ n; Array[a, 70, 0] (* Robert G. Wilson v, Jul 06 2018 *)
  • PARI
    a(n)=n*(n+1)/2-9*sum(k=1,n,sum(i=1,ceil(log(k)/log(10)),floor(k/10^i)))
    
  • PARI
    a(n)={n++;my(t,i,s);c=n;while(c!=0,i++;c\=10);for(j=1,i,d=(n\10^(i-j))%10;t+=(10^(i-j)*(s*d+binomial(d,2)+d*9*(i-j)/2));s+=d);t} \\ David A. Corneth, Aug 16 2013
    
  • Perl
    for $i (0..100){ @j = split "", $i; for (@j){ $sum += $; } print "$sum,"; } __END_ # gamo(AT)telecable.es
    

Formula

a(n) = Sum_{k=0..n} s(k) = Sum_{k=0..n} A007953(k), where s(k) denote the sum of the digits of k in decimal representation. Asymptotic expression: a(n-1) = Sum_{k=0..n-1} s(k) = 4.5*n*log_10(n) + O(n). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Sep 07 2002
a(n) = n*(n+1)/2 - 9*Sum_{k=1..n} Sum_{i=1..ceiling(log_10(k))} floor(k/10^i). - Benoit Cloitre, Aug 28 2003
From Hieronymus Fischer, Jul 11 2007: (Start)
G.f.: Sum_{k>=1} ((x^k - x^(k+10^k) - 9x^(10^k))/(1-x^(10^k)))/(1-x)^2.
a(n) = (1/2)*((n+1)*(n - 18*Sum_{k>=1} floor(n/10^k)) + 9*Sum_{k>=1} (1 + floor(n/10^k))*floor(n/10^k)*10^k).
a(n) = (1/2)*((n+1)*(2*A007953(n)-n) + 9*Sum_{k>=1} (1+floor(n/10^k))*floor(n/10^k)*10^k). (End)
a(n) = A007953(A053064(n)). - Reinhard Zumkeller, Oct 10 2008
From Wojciech Raszka, Jun 14 2019: (Start)
a(10^k - 1) = 10*a(10^(k - 1) - 1) + 45*10^(k - 1) for k > 0.
a(n) = a(n mod m) + MSD*a(m - 1) + (MSD*(MSD - 1)/2)*m + MSD*((n mod m) + 1), where m = 10^(A055642(n) - 1), MSD = A000030(n). (End)

Extensions

More terms from Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Sep 07 2002

A008905 Leading digit of n!.

Original entry on oeis.org

1, 1, 2, 6, 2, 1, 7, 5, 4, 3, 3, 3, 4, 6, 8, 1, 2, 3, 6, 1, 2, 5, 1, 2, 6, 1, 4, 1, 3, 8, 2, 8, 2, 8, 2, 1, 3, 1, 5, 2, 8, 3, 1, 6, 2, 1, 5, 2, 1, 6, 3, 1, 8, 4, 2, 1, 7, 4, 2, 1, 8, 5, 3, 1, 1, 8, 5, 3, 2, 1, 1, 8, 6, 4, 3, 2, 1, 1, 1, 8, 7, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1
Offset: 0

Views

Author

Keywords

Comments

Kunoff proved that the distribution of terms of this sequence follows Benford's law, i.e., the asymptotic density of terms with value d (between 1 and 9) is log_10(1+1/d). - Amiram Eldar, Sep 23 2019

Crossrefs

Cf. A000966, A000142, A018799, A202021 (leading digit of (10^n)!), A213201.

Programs

  • Haskell
    a008905 = a000030 . a000142  -- Reinhard Zumkeller, Apr 08 2012
  • Mathematica
    f[n_] := Quotient[n!, 10^Floor@ Log[10, n!]]; Array[f, 105, 0]

Formula

a(n) = A000030(A000142(n)). - Reinhard Zumkeller, Apr 08 2012

Extensions

Two less-efficient Mathematica codings removed by Robert G. Wilson v, Nov 05 2010

A087097 Lunar primes (formerly called dismal primes) (cf. A087062).

Original entry on oeis.org

19, 29, 39, 49, 59, 69, 79, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 109, 209, 219, 309, 319, 329, 409, 419, 429, 439, 509, 519, 529, 539, 549, 609, 619, 629, 639, 649, 659, 709, 719, 729, 739, 749, 759, 769, 809, 819, 829, 839, 849, 859, 869, 879, 901, 902, 903, 904, 905, 906, 907, 908, 909, 912, 913, 914, 915, 916, 917, 918, 919, 923, 924, 925, 926, 927, 928, 929, 934, 935, 936, 937, 938, 939, 945, 946, 947, 948, 949, 956, 957, 958, 959, 967, 968, 969, 978, 979, 989
Offset: 1

Views

Author

Marc LeBrun, Oct 20 2003

Keywords

Comments

9 is the multiplicative unit. A number is a lunar prime if it is not a lunar product (see A087062 for definition) r*s where neither r nor s is 9.
All lunar primes must contain a 9, so this is a subsequence of A011539.
Also, numbers k such that the lunar sum of the lunar prime divisors of k is k. - N. J. A. Sloane, Aug 23 2010
We have changed the name from "dismal arithmetic" to "lunar arithmetic" - the old name was too depressing. - N. J. A. Sloane, Aug 06 2014
(Lunar) composite numbers are not necessarily a product of primes. (For example 1 = 1*x for any x in {1, ..., 9} is not a prime but can't be written as the product of primes.) Therefore, to establish primality, it is not sufficient to consider only products of primes; one has to consider possible products of composite numbers as well. - M. F. Hasler, Nov 16 2018

Examples

			8 is not prime since 8 = 8*8. 9 is not prime since it is the multiplicative unit. 10 is not prime since 10 = 10*8. Thus 19 is the smallest prime.
		

Crossrefs

Programs

  • PARI
    A87097=select( is_A087097(n)={my(d); if( n<100, n>88||(n%10==9&&n>9), vecmax(d=digits(n))<9, 0, #d<5, vecmin(d)A087062(m,k)==n&&return))))}, [1..999]) \\ M. F. Hasler, Nov 16 2018

Formula

The set { m in A011539 | 9A054054(m) < min(A000030(m),A010879(m)) } (9ish numbers A011539 with 2 digits or such that the smallest digit is strictly smaller than the first and the last digit) is equal to this sequence up to a(1656) = 10099. The next larger 9ish number 10109 is also in that set but is the lunar square of 109, thus not in this sequence of primes. - M. F. Hasler, Nov 16 2018

A037904 Greatest digit of n - least digit of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 9
Offset: 1

Views

Author

Keywords

Comments

a(n) = A054055(n)-A054054(n); a(A010785(n)) = 0; for k>0: a(n) = a(n*10^k + A000030(n)) = a(n*10^k + A010879(n)) = a(n*10^k + A054054(n)) = a(n*10^k + A054055(n)) . - Reinhard Zumkeller, Dec 14 2007; corrected by David Wasserman, May 21 2008

Crossrefs

Programs

  • Haskell
    a037904 = f 9 0 where
       f u v 0 = v - u
       f u v z = f (min u d) (max v d) z' where (z', d) = divMod z 10
    -- Reinhard Zumkeller, Dec 16 2013
    
  • Maple
    f:= n -> (max-min)(convert(n,base,10)):
    map(f, [$1..1000]); # Robert Israel, Jul 07 2016
  • Mathematica
    f[n_] := Block[{d = IntegerDigits[n]}, Max[d] - Min[d]]; Table[ f[n], {n, 1, 15}]
  • PARI
    a(n)=my(d=digits(n)); vecmax(d)-vecmin(d) \\ Charles R Greathouse IV, Feb 07 2017
    
  • Python
    def A037904(n): return int(max(s:=str(n)))-int(min(s)) # Chai Wah Wu, Nov 10 2023

Extensions

Incorrect comments deleted by Robert Israel, Jul 07 2016

A008963 Initial digit of Fibonacci number F(n).

Original entry on oeis.org

0, 1, 1, 2, 3, 5, 8, 1, 2, 3, 5, 8, 1, 2, 3, 6, 9, 1, 2, 4, 6, 1, 1, 2, 4, 7, 1, 1, 3, 5, 8, 1, 2, 3, 5, 9, 1, 2, 3, 6, 1, 1, 2, 4, 7, 1, 1, 2, 4, 7, 1, 2, 3, 5, 8, 1, 2, 3, 5, 9, 1, 2, 4, 6, 1, 1, 2, 4, 7, 1, 1, 3, 4, 8, 1, 2, 3, 5, 8, 1, 2, 3, 6, 9, 1, 2, 4, 6, 1, 1, 2, 4, 7, 1, 1, 3, 5, 8, 1
Offset: 0

Views

Author

Keywords

Comments

Benford's law applies since the Fibonacci sequence is of exponential growth: P(d)=log_10(1+1/d), in fact among first 5000 values the digit d=1 appears 1505 times, while 5000*P(1) is about 1505.15. - Carmine Suriano, Feb 14 2011
Wlodarski observed and Webb proved that the distribution of terms of this sequence follows Benford's law. - Amiram Eldar, Sep 23 2019

Crossrefs

Cf. A000045, A003893 (final digit).

Programs

  • Haskell
    a008963 = a000030 . a000045  -- Reinhard Zumkeller, Sep 09 2015
  • Maple
    F:= combinat[fibonacci]:
    a:= n-> parse(""||(F(n))[1]):
    seq(a(n), n=0..100);  # Alois P. Heinz, Nov 22 2023
  • Mathematica
    Table[IntegerDigits[Fibonacci[n]][[1]], {n, 0, 100}] (* T. D. Noe, Sep 23 2011 *)
  • PARI
    vector(10001,n,f=fibonacci(n-1);f\10^(#Str(f)-1))
    

Formula

a(n) = A000030(A000045(n)). - Amiram Eldar, Sep 23 2019
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = Sum_{d=1..9} d*log(1+1/d)/log(10) = 3.440236... (A213201). - Amiram Eldar, Jan 12 2023
For n>5, a(n) = floor(10^{alpha*n-beta}), where alpha=log_10(phi), beta=log_10(5)/2, {x}=x-floor(x) denotes the fractional part of x, log_10(phi) = A097348, and phi = (1+sqrt(5))/2 = A001622. - Hans J. H. Tuenter, Aug 20 2025

A131835 Numbers starting with 1.

Original entry on oeis.org

1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142
Offset: 1

Views

Author

Andrew Good (yipes_stripes(AT)yahoo.com), Jul 20 2007

Keywords

Comments

The lower and upper asymptotic densities of this sequence are 1/9 and 5/9, respectively. - Amiram Eldar, Feb 27 2021

Crossrefs

Subsequence of A011531.
Disjoint union of A045707 and A206286.
Cf. A000030, A000027, A002275, A262390 (permutation).

Programs

  • Haskell
    a131835 n = a131835_list !! (n-1)
    a131835_list = concat $
                   iterate (concatMap (\x -> map (+ 10 * x) [0..9])) [1]
    -- Reinhard Zumkeller, Jul 16 2014
    
  • Maple
    isA131835 := proc(n) if op(-1,convert(n,base,10)) = 1 then true; else false ; fi ; end: for n from 1 to 300 do if isA131835(n) then printf("%d, ",n) ; fi ; od : # R. J. Mathar, Jul 24 2007
  • Mathematica
    Select[Range[150], IntegerDigits[#][[1]] == 1 &] (* Amiram Eldar, Feb 27 2021 *)
  • PARI
    a(n, {base=10}) = my (o=1); while (n>o, n-=o; o*=base); return (o+n-1) \\ Rémy Sigrist, Jun 23 2017
    
  • PARI
    a(n) = n--; s = #digits(9*n+1); n + 8 * (10^(s-1))/9 + 1/9 \\ David A. Corneth, Jun 23 2017
    
  • PARI
    nxt(n) = my(d = digits(n+1)); if(d[1]==1, n+1, 10^#d) \\ David A. Corneth, Jun 23 2017
    
  • Python
    def A131835(n): return n+(10**(len(str(9*n-8))-1)<<3)//9 # Chai Wah Wu, Dec 07 2024

Formula

A000030(a(n)) = 1. - Reinhard Zumkeller, Jul 16 2014
a(A002275(n)+1) = 10^n for any n >= 0. - Rémy Sigrist, Jun 23 2017
a(n) = n + (8*10^floor(log_10(9*n-8))-8)/9. - Alan Michael Gómez Calderón, May 16 2023

Extensions

More terms from R. J. Mathar, Jul 24 2007

A045708 Primes with first digit 2.

Original entry on oeis.org

2, 23, 29, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A000040.
For primes with initial digit d (1 <= d <= 9) see A045707, A045708, A045709, A045710, A045711, A045712, A045713, A045714, A045715; A073517, A073516, A073515, A073514, A073513, A073512, A073511, A073510, A073509
Cf. A000030, subsequence of A208272.
Column k=2 of A262369.

Programs

  • Haskell
    a045708 n = a045708_list !! (n-1)
    a045708_list = filter ((== 2) . a000030) a000040_list
    -- Reinhard Zumkeller, Mar 16 2012
    
  • Magma
    [p: p in PrimesUpTo(2300) | Intseq(p)[#Intseq(p)] eq 2]; // Vincenzo Librandi, Aug 08 2014
    
  • Mathematica
    Select[Table[Prime[n], {n, 3000}], First[IntegerDigits[#]]==2 &] (* Vincenzo Librandi, Aug 08 2014 *)
  • Python
    from sympy import isprime
    def agen(limit=float('inf')):
      yield 2
      digits, adder = 1, 20
      while True:
        for i in range(1, 10**digits, 2):
          test = adder + i
          if test > limit: return
          if isprime(test): yield test
        digits, adder = digits+1, adder*10
    agento = lambda lim: agen(limit=lim)
    print(list(agento(2222))) # Michael S. Branicky, Feb 23 2021
    
  • Python
    from sympy import primepi
    def A045708(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x+primepi(min(((m:=10**(l:=len(str(x))-1))<<1)-1,x))-primepi(min(3*m-1,x))+sum(primepi(((m:=10**i)<<1)-1)-primepi(3*m-1) for i in range(l))
        return bisection(f,n,n) # Chai Wah Wu, Dec 07 2024

Formula

See A045707 for comments on density of these sequences.

Extensions

More terms from Erich Friedman.
Offset fixed by Reinhard Zumkeller, Mar 15 2012

A008952 Leading digit of 2^n.

Original entry on oeis.org

1, 2, 4, 8, 1, 3, 6, 1, 2, 5, 1, 2, 4, 8, 1, 3, 6, 1, 2, 5, 1, 2, 4, 8, 1, 3, 6, 1, 2, 5, 1, 2, 4, 8, 1, 3, 6, 1, 2, 5, 1, 2, 4, 8, 1, 3, 7, 1, 2, 5, 1, 2, 4, 9, 1, 3, 7, 1, 2, 5, 1, 2, 4, 9, 1, 3, 7, 1, 2, 5, 1, 2, 4, 9, 1, 3, 7, 1, 3, 6, 1, 2, 4, 9, 1, 3, 7, 1, 3, 6, 1, 2, 4, 9, 1, 3
Offset: 0

Views

Author

Keywords

Comments

Statistically, sequence obeys Benford's law, i.e. digit d occurs with probability log_10(1 + 1/d); thus 1 appears about 6.6 times more often than 9. - Lekraj Beedassy, May 04 2005
The most significant digits of the n-th powers of 2 are not cyclic and in the first 1000000 terms, 1 appears 301030 times, 2 appears 176093, 3 appears 124937, 4 appears 96911, 5 appears 79182, 6 appears 66947, 7 appears 57990, 8 appears 51154 and 9 appears 45756 times. - Robert G. Wilson v, Feb 03 2008
In fact the sequence follows Benford's law precisely by the equidistribution theorem. - Charles R Greathouse IV, Oct 11 2015

Crossrefs

Programs

  • Maple
    a:= n-> parse(""||(2^n)[1]):
    seq(a(n), n=0..100);  # Alois P. Heinz, Aug 06 2021
  • Mathematica
    a[n_] := First@ IntegerDigits[2^n]; Array[a, 105, 0] (* Robert G. Wilson v, Feb 03 2008 and corrected Nov 24 2014 *)
  • PARI
    a(n)=digits(2^n)[1] \\ Charles R Greathouse IV, Oct 11 2015
    
  • Python
    def A008952(n): return int(str(1<Chai Wah Wu, Jul 07 2022

Formula

a(n) = [2^n / 10^([log_10(2^n)])] = [2^n / 10^([n*log_10(2)])].
a(n) = A000030(A000079(n)). - Omar E. Pol, Jul 04 2019
Showing 1-10 of 197 results. Next