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-5 of 5 results.

A215879 Written in base 3, n ends in a(n) consecutive nonzero digits.

Original entry on oeis.org

0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 3, 3, 0, 3
Offset: 0

Views

Author

M. F. Hasler, Aug 25 2012

Keywords

Comments

Somehow complementary to A007949, the 3-adic valuation of n.
The base 2 analog of this sequence essentially coincides with the 2-adic valuation A007814 (up to a shift in the index).
One gets back the same sequence by concatenation of the pattern (0,1,1) successively multiplied by a(n)+1 = 1, 2, 2, 1, 3, 3, ... for n = 0, 1, 2, 3, 4, 5, .... This is equivalent to the formula (a(n)+1)*(0, 1, 1) = a(3n, 3n+1, 3n+2). - M. F. Hasler, Aug 26 2012, corrected Aug 23 2022
a(A008585(n)) = 0; a(A001651(n)) > 0. - Reinhard Zumkeller, Dec 28 2012

Examples

			The numbers 0, 1, 2, 3, 4, 5, 6, 7 are written in base 3 as 0, 1, 2, 10, 11, 12, 20, 21 and thus end in a(0..7) = 0, 1, 1, 0, 2, 2, 0, 2 nonzero digits.
		

Crossrefs

The base-4, base-5 and base-10 analogs of this sequence are given in A215883, A215884 and A215887.
Cf. A007089.

Programs

  • Haskell
    a215879 n = if t == 0 then 0 else a215879 n' + 1
                where (n',t) = divMod n 3
    -- Reinhard Zumkeller, Dec 28 2012
    
  • Mathematica
    cnzd[n_]:=Module[{idn3=IntegerDigits[n,3],len},len=Length[idn3];Which[ idn3[[len]] == 0,0,Position[idn3,0]=={},len,True,len-Position[idn3,0] [[-1,1]]]]; Array[cnzd,110,0] (* Harvey P. Dale, Jun 07 2016 *)
  • PARI
    A215879(n,b=3)=n=divrem(n,b); for(c=0,oo,n[2]||return(c); n=divrem(n[1],b))
    
  • PARI
    a(n)=my(k);while(n%3,n\=3;k++);k \\ Charles R Greathouse IV, Sep 26 2013
    
  • Python
    def A215879(n):
        c = 0
        while (a:=divmod(n,3))[1]:
            c += 1
            n = a[0]
        return c # Chai Wah Wu, Oct 15 2022

Formula

a(3^(t+1)*k+m) = t for 3^t > m > 3^(t-1).
a(3n) = 0, a(3n+1) = a(3n+2) = a(n)+1. - M. F. Hasler, Aug 26 2012, corrected thanks to a remark from Jianing Song, Aug 23 2022

A215884 Written in base 5, n ends in a(n) consecutive nonzero digits.

Original entry on oeis.org

0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 1, 1, 1, 1, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0, 3
Offset: 0

Views

Author

M. F. Hasler, Aug 25 2012

Keywords

Comments

Sequences A215879, A215883 and A215887 are the base 3, 4 and 10 analogs, while the base 2 analog of this sequence coincides (up to a shift in the index) with the 2-adic valuation A007814, cf. comments there.

Examples

			The numbers 24,...,31 are written in base 5 as 44,100,101,102,103,104,110,111 and thus end in a string of a(24..31)=2,0,1,1,1,1,0,3 nonzero digits.
		

Programs

  • Mathematica
    cnzd[n_]:=Module[{c=Split[If[#>0,1,0]&/@IntegerDigits[n,5]]},If[FreeQ[ c[[-1]],0],Total[c[[-1]]],0]]; Array[cnzd,120,0] (* Harvey P. Dale, Jan 03 2023 *)
  • PARI
    a(n,b=5)=n=divrem(n,b); for(c=0,9e9,n[2]||return(c); n=divrem(n[1],b))
    
  • PARI
    a(n)=my(k);while(n%5,n\=5;k++);k \\ Charles R Greathouse IV, Sep 26 2013

A215883 When written in base 4, n ends in a(n) consecutive nonzero digits.

Original entry on oeis.org

0, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 1, 1, 1, 0, 4, 4
Offset: 0

Views

Author

M. F. Hasler, Aug 25 2012

Keywords

Comments

Sequences A215879, A215884 and A215887 are the base 3, 5 and 10 analog, while the base 2 analog of this sequence coincides (up to a shift in the index) with the 2-adic valuation A007814, see comments there.

Examples

			The numbers 0,1,2,3,4,5,6,7 are written in base 4 as 0,1,2,3,10,11,12,13 and thus end in a(0..7)=0,1,1,1,0,2,2,2 nonzero digits.
		

Programs

  • PARI
    a(n,b=4)=n=divrem(n,b); for(c=0,9e9,n[2]||return(c); n=divrem(n[1],b))
    
  • PARI
    a(n)=my(k);while(n%4,n>>=2;k++);k \\ Charles R Greathouse IV, Sep 26 2013

Formula

a(4^(t+1)*k+m) = t for 4^t > m > 4^(t-1).

A339012 Written in factorial base, n ends in a(n) consecutive non-0 digits.

Original entry on oeis.org

0, 1, 0, 2, 0, 2, 0, 1, 0, 3, 0, 3, 0, 1, 0, 3, 0, 3, 0, 1, 0, 3, 0, 3, 0, 1, 0, 2, 0, 2, 0, 1, 0, 4, 0, 4, 0, 1, 0, 4, 0, 4, 0, 1, 0, 4, 0, 4, 0, 1, 0, 2, 0, 2, 0, 1, 0, 4, 0, 4, 0, 1, 0, 4, 0, 4, 0, 1, 0, 4, 0, 4, 0, 1, 0, 2, 0, 2, 0, 1, 0, 4, 0, 4, 0, 1, 0
Offset: 0

Views

Author

Kevin Ryde, Nov 19 2020

Keywords

Comments

Also, a(n) is the least p for which n mod (p+2)! < (p+1)!. A small remainder like this means a 0 digit at position p in the factorial base representation of n, where the least significant digit is position p=0. The least such p means only nonzero digits below.
Those n with a(n)=p are characterized by remainders n mod (p+2)!, per the formula below. These remainders are terms of A227157 which is factorial base digits all nonzero. A227157 can be taken by rows where row p lists the terms having p digits in factorial base. Each digit ranges from 1 up to 1,2,3,... respectively so there are p! values in a row, and so the asymptotic density of terms p here is p!/(p+2)! = 1/((p+2)*(p+1)) = 1/A002378(p+1) = 1/2, 1/6, etc.
The smallest n with a(n)=p is the factorial base repunit n = 11..11 with p 1's = A007489(p).

Examples

			n = 10571 written in factorial base is 2,0,4,0,1,2,1.  It ends in 3 consecutive nonzero digits (1,2,1) so a(10571) = 3.  Remainder 10571 mod (3+2)! = 11 is in A227157 row 3.
		

Crossrefs

Cf. A108731 (factorial base digits), A016921 (where a(n)=1), A339013 (+2), A230403 (ending 0's).
In other bases: A215887, A328570.

Programs

  • Mathematica
    a[n_] := Module[{k = n, m = 2, r}, While[{k, r} = QuotientRemainder[k, m]; r != 0, m++]; m - 2]; Array[a, 30, 0] (* Amiram Eldar, Feb 15 2021 after Kevin Ryde's PARI code *)
  • PARI
    a(n) = my(b=2,r); while([n,r]=divrem(n,b);r!=0, b++); b-2;

Formula

a(n)=p iff n mod (p+2)! is a term in row p of A227157 (row p terms having p digits), including p=0 by reckoning an initial A227157(0) = 0 as no digits.
a(n)=0 iff n mod 2 = 0.
a(n)=1 iff n mod 6 = 1, which is A016921.
a(n)=2 iff n mod 24 = 3 or 5.

A181611 Position of rightmost zero in 2^n (including leading zero).

Original entry on oeis.org

1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 4, 5, 5, 5, 2, 6, 6, 5, 5, 1, 1, 8, 8, 4, 9, 9, 3, 8, 10, 10, 10, 11, 11, 11, 12, 4, 12, 11, 8, 1, 1, 5, 5, 12, 12, 3, 15, 7, 16, 3, 3, 7, 8, 8, 8, 12, 7, 7, 10, 1, 1, 7, 4, 4, 21, 13, 7, 4, 4, 22, 6, 6, 4, 23, 24, 13, 2, 4, 25, 1, 1, 11, 6, 26, 3, 2, 12, 12, 12, 11, 14, 14, 23, 3, 3, 4, 4, 4, 3, 1, 1, 2, 2, 2, 6, 6, 8, 2, 2, 2, 3, 3, 3, 17, 2, 5, 6, 6, 6
Offset: 1

Views

Author

Tanya Khovanova, Jan 30 2011

Keywords

Comments

"Positions" are counted 0,1,2,3,... starting with the least significant digit.

Examples

			2^10 = 1024, the rightmost zero is in position 2, so a(10) = 2. Another example, 2^5 = 32, so we need to add a leading zero: 032, thus the rightmost zero will be in position 2, and a(5) = 2.
		

Crossrefs

Programs

  • Maple
    A181611 := proc(n) local dgs,i ; dgs := convert(2^n, base, 10) ; i := ListTools[Search](0, dgs) ; if i > 0 then i-1; else nops(dgs) ; end if ; end proc: # R. J. Mathar, Jan 30 2011
    a:= proc(n) local m, i;
          m:= 2^n;
          for i from 0 while m>0 and irem(m, 10, 'm')<>0
          do od; i
        end:
    seq(a(n), n=1..121);  # Alois P. Heinz, Feb 05 2011
  • Mathematica
    Table[Position[Reverse[Prepend[IntegerDigits[2^n], 0]],
        0][[1]][[1]] - 1, {n, 121}]
  • PARI
    a(n) = {my(d = Vecrev(digits(2^n))); for (i=1, #d, if (!d[i], return (i-1));); #d;} \\ Michel Marcus, Jan 01 2016

Formula

a(n) = A215887(A000079(n)). - Michel Marcus, Jan 01 2016
Showing 1-5 of 5 results.