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 11-20 of 28 results. Next

A142149 a(n) = XOR{k OR (n-k): 0<=k<=n}.

Original entry on oeis.org

0, 1, 3, 3, 6, 5, 5, 7, 12, 9, 15, 11, 10, 13, 9, 15, 24, 17, 27, 19, 30, 21, 29, 23, 20, 25, 23, 27, 18, 29, 17, 31, 48, 33, 51, 35, 54, 37, 53, 39, 60, 41, 63, 43, 58, 45, 57, 47, 40, 49, 43, 51, 46, 53, 45, 55, 36, 57, 39, 59, 34, 61, 33, 63, 96, 65, 99, 67, 102, 69, 101, 71
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 15 2008

Keywords

Comments

a(n) = XOR{k AND (n-k): 0<=k<=n}.

Crossrefs

Programs

  • Haskell
    import Data.Bits (xor, (.|.))
    a142149 :: Integer -> Integer
    a142149 = foldl xor 0 . zipWith (.|.) [0..] . reverse . enumFromTo 1
    -- Reinhard Zumkeller, Mar 31 2015
    
  • PARI
    a(n)=if(n%2, n, bitxor(n, n/2)) \\ Charles R Greathouse IV, Jul 01 2022
  • Python
    def A142149(n): return n if n&1 else (n^ n>>1) # Chai Wah Wu, Jun 29 2022
    

Formula

a(2*n) = A048724(n) and a(2*n+1) = A005408(n).

A167832 A167831(n) + n.

Original entry on oeis.org

0, 2, 4, 6, 8, 9, 9, 9, 9, 9, 20, 22, 24, 26, 28, 29, 29, 29, 29, 29, 40, 42, 44, 46, 48, 49, 49, 49, 49, 49, 60, 62, 64, 66, 68, 69, 69, 69, 69, 69, 80, 82, 84, 86, 88, 89, 89, 89, 89, 89, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 14 2009

Keywords

Comments

No carry occurs when calculating a(n) by adding A167831(n) to n in decimal arithmetic.

Crossrefs

Cf. A167878, A003817 for the ternary and binary cases.

Programs

A218388 Bitwise OR of all divisors of n.

Original entry on oeis.org

1, 3, 3, 7, 5, 7, 7, 15, 11, 15, 11, 15, 13, 15, 15, 31, 17, 31, 19, 31, 23, 31, 23, 31, 29, 31, 27, 31, 29, 31, 31, 63, 43, 51, 39, 63, 37, 55, 47, 63, 41, 63, 43, 63, 47, 63, 47, 63, 55, 63, 51, 63, 53, 63, 63, 63, 59, 63, 59, 63, 61, 63, 63, 127, 77, 127
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 27 2012

Keywords

Comments

a(n) <= A003817(n); a(A000040(n)) = A000040(n).

Examples

			n=20: divisors(20) = {1, 2, 4, 5, 10, 20}, 00001 OR 00010 OR 00100 OR 00101 OR 01010 OR 10100 = 11111 -> a(20) = 31;
n=21: divisors(21) = {1, 3, 7, 21}, 00001 OR 00011 OR 00111 OR 10101 = 10111 -> a(21) = 23;
n=22: divisors(22) = {1, 2, 11, 22}, 00001 OR 00010 OR 01011 OR 10110 = 11111 -> a(22) = 31;
n=23: divisors(23) = {1, 23}, 00001 OR 10111 = 10111 -> a(23) = 23;
n=24: divisors(24) = {1, 2, 3, 4, 6, 8, 12, 24}, 00001 OR 00010 OR 00011 OR 00100 OR 00110 OR 01000 OR 01100 OR 11000 = 11111 -> a(24) = 31;
n=25: divisors(25) = {1, 5, 25}, 00001 OR 00101 OR 11001 = 11101 -> a(25) = 29.
		

Crossrefs

Cf. A027750, A000225 (subsequence), A123345, A218403.

Programs

  • Haskell
    import Data.Bits ((.|.))
    a218388 = foldl1 (.|.) . a027750_row :: Integer -> Integer
  • Mathematica
    Table[BitOr@@Divisors[n],{n,70}] (* Harvey P. Dale, Feb 27 2013 *)

A361644 Irregular triangle T(n, k), n >= 0, k = 1..max(1, 2^(A005811(n)-1)), read by rows; the n-th row lists the integers with the same binary length as n and whose partial sums of run lengths are included in those of n.

Original entry on oeis.org

0, 1, 2, 3, 3, 4, 7, 4, 5, 6, 7, 6, 7, 7, 8, 15, 8, 9, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 8, 11, 12, 15, 12, 15, 12, 13, 14, 15, 14, 15, 15, 16, 31, 16, 17, 30, 31, 16, 17, 18, 19, 28, 29, 30, 31, 16, 19, 28, 31, 16, 19, 20, 23, 24, 27, 28, 31
Offset: 0

Views

Author

Rémy Sigrist, Mar 19 2023

Keywords

Comments

In other words, the n-th row contains the numbers k with the same binary length as n and for any i >= 0, if the i-th bit and the (i+1)-th bit in k are different then they are also different in n (i = 0 corresponding to the least significant bit).
The value m appears 2^A092339(m) times in the triangle (see A361674).

Examples

			Triangle begins (in decimal and in binary):
  n   n-th row      bin(n)  n-th row in binary
  --  ------------  ------  ------------------
   0  0                  0  0
   1  1                  1  1
   2  2, 3              10  10, 11
   3  3                 11  11
   4  4, 7             100  100, 111
   5  4, 5, 6, 7       101  100, 101, 110, 111
   6  6, 7             110  110, 111
   7  7                111  111
   8  8, 15           1000  1000, 1111
   9  8, 9, 14, 15    1001  1000, 1001, 1110, 1111
.
For n = 9:
- the binary expansion of 9 is "1001",
- the corresponding run lengths are 1, 2, 1,
- so the 9th row contains the values with the following run lengths:
      1, 2, 1  ->   9 ("1001" in binary)
      1,  2+1  ->   8 ("1000" in binary)
      1+2,  1  ->  14 ("1110" in binary)
       1+2+1   ->  15 ("1111" in binary)
		

Crossrefs

Programs

  • PARI
    row(n) = { my (r = []); while (n, my (v = valuation(n+n%2, 2)); n \= 2^v; r = concat(v, r)); my (s = [if (#r, 2^r[1]-1, 0)]); for (k = 2, #r, s = concat(s * 2^r[k], [(h+1)*2^r[k]-1|h<-s]);); vecsort(s); }

Formula

T(n, 1) = A342126(n).
T(n, max(1, 2^(A005811(n)-1))) = A003817(n).

A092323 2^m - 1 appears 2^m times.

Original entry on oeis.org

0, 1, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
Offset: 1

Views

Author

Reinhard Zumkeller, Feb 15 2004

Keywords

Comments

Or, write n in binary and change the most significant bit to 0 and all other bits to 1.
a(n) = A053644(n) - 1 = A003817(n) - A053644(n).
a(n) = floor(A003817(n-1)/2). [Reinhard Zumkeller, Jul 18 2010]

Crossrefs

Programs

  • Magma
    [n le 2 select n-1 else Self(Floor(n/2))*2+1: n in [1..100]]; // Vincenzo Librandi, Jun 27 2016
  • Mathematica
    Table[FromDigits[#, 2] &@ Table[1, {IntegerLength[n, 2] - 1}], {n, 80}] (* Michael De Vlieger, Jun 26 2016 *)
    Table[Table[2^m-1,2^m],{m,0,6}]//Flatten (* Harvey P. Dale, May 22 2021 *)
    Table[PadRight[{},2^m,2^m-1],{m,0,6}]//Flatten (* Harvey P. Dale, Aug 18 2025 *)

Formula

a(n) = if n=1 then 0 else a(floor(n/2))*2 + 1.
a(1)=0, a(2n) = 2*a(n)+1, a(2n+1) = a(2n). - Ralf Stephan, Nov 18 2010

A167878 A167877(n) + n.

Original entry on oeis.org

0, 2, 2, 6, 8, 8, 8, 8, 8, 18, 20, 20, 24, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 54, 56, 56, 60, 62, 62, 62, 62, 62, 72, 74, 74, 78, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 14 2009

Keywords

Comments

No carry occurs when calculating a(n) by adding A167877(n) to n in ternary arithmetic.

Crossrefs

Cf. A007089, see A167832, A003817 for the decimal and binary cases.

Programs

A340632 a(n) in binary is a run of 1-bits from the most significant 1-bit of n down to the least significant 1-bit of n, inclusive.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 6, 7, 8, 15, 14, 15, 12, 15, 14, 15, 16, 31, 30, 31, 28, 31, 30, 31, 24, 31, 30, 31, 28, 31, 30, 31, 32, 63, 62, 63, 60, 63, 62, 63, 56, 63, 62, 63, 60, 63, 62, 63, 48, 63, 62, 63, 60, 63, 62, 63, 56, 63, 62, 63, 60, 63, 62, 63, 64, 127, 126
Offset: 0

Views

Author

Kevin Ryde, Jan 13 2021

Keywords

Examples

			n    = 172 = binary 10101100;
a(n) = 252 = binary 11111100.
		

Crossrefs

Cf. A023758 (distinct terms).

Programs

  • PARI
    a(n) = if(n, 2<
    				
  • Python
    def a(n): return (1<
    				

Formula

a(n) = A062383(n) - A006519(n) for n>=1.
a(n) = A003817(n) - A135481(n-1).
a(n) = n + A334045(n) (filling in 0-bits, including n=0 by taking A334045(0)=0).
a(n) = A142151(n-1) + 1.
G.f.: x/(1-x) + Sum_{k>=0} 2^k*x^(2^k)*(1/(1-x) - 1/(1-x^(2^(k+1)))).

A342698 For any number n with binary expansion (b(1), b(2), ..., b(k)), the binary expansion of a(n) is (floor((b(k)+b(1)+b(2))/2), floor((b(1)+b(2)+b(3))/2), ..., floor((b(k-1)+b(k)+b(1))/2)).

Original entry on oeis.org

0, 1, 1, 3, 0, 7, 7, 7, 0, 9, 5, 15, 12, 15, 15, 15, 0, 17, 1, 19, 8, 27, 15, 31, 24, 25, 29, 31, 28, 31, 31, 31, 0, 33, 1, 35, 0, 35, 7, 39, 16, 49, 21, 55, 28, 63, 31, 63, 48, 49, 49, 51, 56, 59, 63, 63, 56, 57, 61, 63, 60, 63, 63, 63, 0, 65, 1, 67, 0, 67, 7
Offset: 0

Views

Author

Rémy Sigrist, Mar 18 2021

Keywords

Comments

This sequence is a variant of A342697; here we deal with bit triples in a "cyclic" binary representation of n.

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1      10          1
   3     3      11         11
   4     0     100          0
   5     7     101        111
   6     7     110        111
   7     7     111        111
   8     0    1000          0
   9     9    1001       1001
  10     5    1010        101
  11    15    1011       1111
  12    12    1100       1100
  13    15    1101       1111
  14    15    1110       1111
  15    15    1111       1111
		

Crossrefs

Cf. A003817, A342697, A342699 (fixed points), A342700.

Programs

  • PARI
    a(n) = my (w=#binary(n)); sum(k=0, w-1, ((bittest(n, (k-1)%w)+bittest(n, k%w)+bittest(n, (k+1)%w))>=2) * 2^k)

Formula

a(n) + A342700(n) = A003817(n).
a(n) = n iff n belongs to A342699.

A355222 The k-th leftmost digit of a(n) is the greatest of the k leftmost digits of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 22, 22, 23, 24, 25, 26, 27, 28, 29, 33, 33, 33, 33, 34, 35, 36, 37, 38, 39, 44, 44, 44, 44, 44, 45, 46, 47, 48, 49, 55, 55, 55, 55, 55, 55, 56, 57, 58, 59, 66, 66, 66, 66, 66, 66, 66, 67
Offset: 0

Views

Author

Rémy Sigrist, Jun 24 2022

Keywords

Comments

Leading zeros are ignored.

Examples

			For n = 1402: max({1}) = 1, max({1, 4}) = 4, max({1, 4, 0}) = 4, max({1, 4, 0, 2}) = 4, so a(1402) = 1444.
		

Crossrefs

See A355221, A355223 and A355224 for similar sequences.
Cf. A003817 (binary analog), A009994 (fixed points).

Programs

  • PARI
    a(n, base=10) = { my (d=digits(n, base), m=-oo); for (k=1, #d, d[k]=m=max(m, d[k])); fromdigits(d, base) }
    
  • Python
    def a(n):
        s, m = str(n), "0"
        return int("".join((m:=max(m, s[k])) for k in range(len(s))))
    print([a(n) for n in range(68)]) # Michael S. Branicky, Jun 24 2022
    
  • Python
    from itertools import accumulate
    def A355222(n): return int(''.join(accumulate(str(n),func=max))) # Chai Wah Wu, Jun 25 2022

Formula

a(n) >= n with equality iff n belongs to A009994.
a(a(n)) = a(n).

A179526 (3^k - 1)/2 appears 3^(k-1) times, k>0.

Original entry on oeis.org

1, 4, 4, 4, 13, 13, 13, 13, 13, 13, 13, 13, 13, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 18 2010

Keywords

Crossrefs

Programs

  • Mathematica
    Table[PadRight[{},3^(k-1),(3^k-1)/2],{k,5}]//Flatten (* Harvey P. Dale, May 30 2021 *)

Formula

a(n+1) = 3*a(floor(n/3)) + 1; a(0) = 1.

Extensions

Erroneous comment deleted by Reinhard Zumkeller, Jul 23 2010
Previous Showing 11-20 of 28 results. Next