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.

Previous Showing 31-40 of 74 results. Next

A171960 Values of the 2-complement of n in ternary representation.

Original entry on oeis.org

2, 1, 0, 5, 4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Jan 20 2010

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := 3^(1 + Floor[Log[3, n]]) - n - 1; a[0] = 2; Array[a, 100] (* Amiram Eldar, Apr 03 2025 *)
  • PARI
    a(n) = 3^(if(n,logint(n,3))+1) - 1 - n; \\ Kevin Ryde, Jul 16 2020

Formula

a(n) = if n < 3 then 2 - n else 3*a(floor(n/3)) + 2 - n mod 3.
a(A134026(n)) < A134026(n).
a(A003462(n)) = A003462(n).
a(A134025(n)) >= A134025(n).

A256293 Apply the transformation 0 -> 1 -> 2 -> 0 to the digits of n written in base 3, then convert back to base 10.

Original entry on oeis.org

1, 2, 0, 7, 8, 6, 1, 2, 0, 22, 23, 21, 25, 26, 24, 19, 20, 18, 4, 5, 3, 7, 8, 6, 1, 2, 0, 67, 68, 66, 70, 71, 69, 64, 65, 63, 76, 77, 75, 79, 80, 78, 73, 74, 72, 58, 59, 57, 61, 62, 60, 55, 56, 54, 13, 14, 12, 16, 17, 15
Offset: 0

Views

Author

M. F. Hasler, Mar 22 2015

Keywords

Comments

Base 3 variant of A035327 (base 2) and A048379 (base 10).
See A256294 - A256299 for bases 4 through 9, and A256303 for the variant where the result is not converted back to base 10.

Examples

			a(3) = 7 because 3 = 10[3] becomes 21[3] = 7.
a(8) = 0 because 8 = 22[3] becomes 00[3] = 0.
		

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[n,3]/.{0->1,1->2,2->0},3],{n,0,100}] (* Harvey P. Dale, Jan 21 2019 *)
  • PARI
    A256293(n,b=3)=!n+apply(t->(t+1)%b,n=digits(n,b))*vector(#n,i,b^(#n-i))~

A256299 Apply the transformation 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 0 to the digits of n written in base 9, then convert back to base 10.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 0, 19, 20, 21, 22, 23, 24, 25, 26, 18, 28, 29, 30, 31, 32, 33, 34, 35, 27, 37, 38, 39, 40, 41, 42, 43, 44, 36, 46, 47, 48, 49, 50, 51, 52, 53, 45, 55, 56, 57, 58, 59, 60, 61, 62, 54, 64, 65, 66, 67, 68, 69
Offset: 0

Views

Author

M. F. Hasler, Mar 22 2015

Keywords

Comments

Base 9 variant of A035327 (base 2) and A048379 (base 10). See A256293 - A256298 for bases 3 through 8, and A256289 for the variant where the result is not converted back to base 10.

Examples

			a(9) = 19 because 9 = 10[9] becomes 21[9] = 19.
a(80) = 0 because 80 = 88[9] becomes 00[9] = 0.
		

Programs

  • PARI
    A256299(n,b=9)=!n+apply(t->(t+1)%b,n=digits(n,b))*vector(#n,i,b^(#n-i))~

A359208 Maximum value reached when starting from n during iteration of the map x->A359194(x) (binary complement of 3n), or -1 if infinite.

Original entry on oeis.org

0, 1, 2, 300, 300, 5, 300, 10, 10, 300, 10, 300, 328536, 300, 21, 300, 300, 328536, 300, 300, 300, 21, 72, 328536, 300, 328536, 661, 328536, 123130640068522377168864228132316865867184046004226894, 40, 300, 328536, 328536
Offset: 0

Views

Author

Joshua Searle, Dec 20 2022

Keywords

Comments

It is unknown whether any terms are -1. The next term a(33) is equal to a(28), a 54-digit number. a(425720) is >= 2.09 * 10^114778, unresolved after 10^10 iterations.
a(425720) = 7.14... * 10^179246. - Joshua Searle, Jan 10 2023

Examples

			a(3) = 300 because the largest term in the iterated sequence: (3, 6, 13, 24, 55, 90, 241, 300, 123, 142, 85, 0) is 300.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := BitXor[3 n, 2^IntegerPart[Log2[3 n] + 1] - 1]; Table[Max@ NestWhileList[f, n, # != 0 &], {n, 0, 32}] (* Michael De Vlieger, Dec 21 2022 *)
  • PARI
    f(n) = if(n, bitneg(n, exponent(n)+1), 1); \\ A035327
    a(n) = my(x=n, m=n); while (m, m=f(3*m); if (m>x, x=m)); x; \\ Michel Marcus, Dec 21 2022
  • Python
    def f(n): return 1 if n == 0 else (m:=3*n)^((1 << m.bit_length())-1)
    def a(n):
        i, fi, m = 0, n, n
        while fi != 0: i, fi, m = i+1, f(fi), max(m, fi)
        return m
    print([a(n) for n in range(33)]) # Michael S. Branicky, Dec 20 2022
    

A240857 Triangle read by rows: T(0,0) = 0; T(n+1,k) = T(n,k+1), 0 <= k < n; T(n+1,n) = T(n,0); T(n+1,n+1) = T(n,0)+1.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Apr 14 2014

Keywords

Comments

Let h be the initial term of row n, to get row n+1, remove h and then append h and h+1.

Examples

			.   0:                                 0
.   1:                               0   1
.   2:                             1   0   1
.   3:                           0   1   1   2
.   4:                         1   1   2   0   1
.   5:                       1   2   0   1   1   2
.   6:                     2   0   1   1   2   1   2
.   7:                   0   1   1   2   1   2   2   3
.   8:                 1   1   2   1   2   2   3   0   1
.   9:               1   2   1   2   2   3   0   1   1   2
.  10:             2   1   2   2   3   0   1   1   2   1   2
.  11:           1   2   2   3   0   1   1   2   1   2   2   3
.  12:         2   2   3   0   1   1   2   1   2   2   3   1   2
.  13:       2   3   0   1   1   2   1   2   2   3   1   2   2   3
.  14:     3   0   1   1   2   1   2   2   3   1   2   2   3   2   3
.  15:   0   1   1   2   1   2   2   3   1   2   2   3   2   3   3   4 .
		

Crossrefs

Cf. A048881 (left edge), A000120 (right edge), A000788 (row sums), A000523 (row maxima), A240883 (central terms).
Cf. A035327.

Programs

  • Haskell
    a240857 n k = a240857_tabl !! n !! k
    a240857_row n = a240857_tabl !! n
    a240857_tabl = iterate (\(x:xs) -> xs ++ [x, x + 1]) [0]
    
  • Mathematica
    T[n_, k_] := DigitCount[n + k + 1, 2, 1] - 1; Table[T[n, k], {n, 0, 12}, {k, 0, n}] // Flatten (* Amiram Eldar, Aug 01 2023 *)
  • Python
    from math import isqrt
    def A240857(n): return (n-((r:=(m:=isqrt(k:=n+1<<1))+(k>m*(m+1)))*(r-3)>>1)).bit_count()-1 # Chai Wah Wu, Nov 11 2024

Formula

T(n,k) = A048881(n+k), 0 <= k <= n.
For n > 0: T(n,A035327(n)) = 0.

A326699 Numerator of the average position of a 1 in the reversed binary expansion of n.

Original entry on oeis.org

1, 2, 3, 3, 2, 5, 2, 4, 5, 3, 7, 7, 8, 3, 5, 5, 3, 7, 8, 4, 3, 10, 11, 9, 10, 11, 3, 4, 13, 7, 3, 6, 7, 4, 3, 9, 10, 11, 3, 5, 11, 4, 13, 13, 7, 15, 16, 11, 4, 13, 7, 14, 15, 4, 17, 5, 4, 17, 18, 9, 19, 4, 7, 7, 4, 9, 10, 5, 11, 4, 13, 11, 4, 13, 7, 14, 15, 4
Offset: 1

Views

Author

Gus Wiseman, Jul 20 2019

Keywords

Examples

			The sequence of fractions begins: 1, 2, 3/2, 3, 2, 5/2, 2, 4, 5/2, 3, 7/3, 7/2, 8/3, 3, 5/2, 5, 3, 7/2, 8/3, 4.
For example, the reversed binary expansion of 18 is (0,1,0,0,1), and the average of {2,5} is 7/2, so a(18) = 7.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L;
      L:= convert(n,base,2);
      L:= select(t -> L[t]=1, [$1..nops(L)]);
      numer(convert(L,`+`)/nops(L))
    end proc:
    map(f, [$1..100]); # Robert Israel, Oct 07 2019
  • Mathematica
    Table[Numerator[Mean[Join@@Position[Reverse[IntegerDigits[n,2]],1]]],{n,100}]

A326700 Denominator of the average position of a 1 in the reversed binary expansion of n.

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 2, 3, 1, 2, 1, 1, 2, 3, 1, 1, 3, 4, 2, 3, 3, 1, 1, 4, 2, 1, 1, 2, 1, 1, 2, 3, 3, 1, 1, 3, 1, 4, 3, 2, 4, 5, 2, 1, 3, 2, 3, 4, 1, 5, 1, 1, 4, 5, 2, 5, 1, 2, 1, 1, 2, 3, 1, 3, 1, 4, 2, 1, 3, 2, 3, 4, 1, 5, 1, 3, 3, 4, 1, 1, 4, 5
Offset: 1

Views

Author

Gus Wiseman, Jul 20 2019

Keywords

Comments

The sequence of fractions begins: 1, 2, 3/2, 3, 2, 5/2, 2, 4, 5/2, 3, 7/3, 7/2, 8/3, 3, 5/2, 5, 3, 7/2, 8/3, 4.
For example, the reversed binary expansion of 18 is (0,1,0,0,1), and the average of {2,5} is 7/2, so a(18) = 2.
a(n) divides A000120(n). - Robert Israel, Oct 07 2019

Crossrefs

Positions of 1's are A326669.

Programs

  • Maple
    f:= proc(n) local L;
      L:= convert(n,base,2);
      L:= select(t -> L[t]=1, [$1..nops(L)]);
      denom(convert(L,`+`)/nops(L))
    end proc:
    map(f, [$1..100]); # Robert Israel, Oct 07 2019
  • Mathematica
    Table[Denominator[Mean[Join@@Position[Reverse[IntegerDigits[n,2]],1]]],{n,100}]

A359209 Numbers that under iteration of the map x->A359194(x) (binary complement of 3n) until 0 is reached never exceed the initial term.

Original entry on oeis.org

0, 1, 2, 5, 10, 21, 39, 40, 42, 71, 72, 78, 85, 142, 150, 157, 163, 167, 168, 170, 285, 291, 300, 303, 311, 313, 315, 316, 317, 319, 320, 321, 322, 327, 328, 329, 331, 333, 334, 335, 336, 338, 339, 340, 341, 569, 571, 572, 573, 575, 576, 577, 578, 579
Offset: 1

Views

Author

Joshua Searle, Dec 20 2022

Keywords

Comments

If it can be shown that all iterations of A359194 eventually reach one of the terms of this sequence, it would prove that all such trajectories are finite.
From M. F. Hasler, Dec 26 2022: (Start)
(1) If A359194(x) = a(k) for some a(k) < x, then x is also in the sequence.
(2) The orbit of any x under iterations of A359194 is finite if and only if it reaches a term of this sequence.
(3) No term has binary digits starting with '11...', i.e., all terms > 1 have binary digits starting '10...'.
(4) If the 3rd binary digit of a(n) is a '1', it cannot be followed by another bit 1, so all terms > 5 have a binary representation of the form '100...' or '1010...'
(5) A substring of '11', i.e., two consecutive bits 1, in a term of this sequence, is necessarily preceded by an earlier substring '00', i.e., two consecutive bits 0 to the left of the '11'. [This implies (3) and (4).] (End)

Examples

			40 is a term since its trajectory is 40 -> 7 -> 10 -> 1 -> 0, which never exceeds 40.
		

Crossrefs

Programs

  • Maple
    bc:= n -> 2^(1+ilog2(n))-1-n: bc(0):= 1:
    filter:= proc(n) local x;
      x:= n;
      while x <> 0 do
        x:= bc3(x);
        if x > n then return false fi;
      od;
      true
    end proc:
    select(filter, [$0..1000]); # Robert Israel, Dec 22 2022
  • Mathematica
    f[n_] := BitXor[3 n, 2^IntegerPart[Log2[3 n] + 1] - 1]; Select[Range[0, 200], Function[n, AllTrue[NestWhileList[f, n, # != 0 &], # <= n &]]] (* Michael De Vlieger, Dec 21 2022 *)
  • PARI
    f(n) = if(n, bitneg(n, exponent(n)+1), 1); \\ A035327
    isok(m) = my(km=m); while (m, m=f(3*m); if (m>km, return(0))); return(1); \\ Michel Marcus, Dec 21 2022
  • Python
    def f(n): return 1 if n == 0 else (m:=3*n)^((1 << m.bit_length())-1)
    def ok(n):
        i, fi, m = 0, n, n
        while fi != 0 and m <= n: i, fi, m = i+1, f(fi), max(m, fi)
        return m <= n
    print([k for k in range(580) if ok(k)]) # Michael S. Branicky, Dec 20 2022
    

A167831 Largest m<=n such that no carry occurs when adding m to n in decimal arithmetic.

Original entry on oeis.org

0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 14, 13, 12, 11, 10, 20, 21, 22, 23, 24, 24, 23, 22, 21, 20, 30, 31, 32, 33, 34, 34, 33, 32, 31, 30, 40, 41, 42, 43, 44, 44, 43, 42, 41, 40, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 14 2009

Keywords

Comments

A167832(n) = a(n) + n.

Crossrefs

Cf. A167877, A035327 for the ternary and binary cases.
Cf. A031298.

Programs

  • Haskell
    a167831 n = head [x | let ds = a031298_row n, x <- [n, n-1 ..],
                          all (< 10) $ zipWith (+) ds (a031298_row x)]
    -- Reinhard Zumkeller, Mar 15 2014

A167877 Largest m<=n such that no carry occurs when adding m to n in ternary arithmetic.

Original entry on oeis.org

0, 1, 0, 3, 4, 3, 2, 1, 0, 9, 10, 9, 12, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 27, 28, 27, 30, 31, 30, 29, 28, 27, 36, 37, 36, 39, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 14 2009

Keywords

Comments

A167878(n) = a(n) + n.

Crossrefs

Cf. A007089, A167831, A035327 for the decimal and binary cases.
Cf. A030341.

Programs

  • Haskell
    a167877 n = head [x | let ts = a030341_row n, x <- [n, n-1 ..],
                          all (< 3) $ zipWith (+) ts (a030341_row x)]
    -- Reinhard Zumkeller, Mar 15 2014
Previous Showing 31-40 of 74 results. Next