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

A006519 Highest power of 2 dividing n.

Original entry on oeis.org

1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 32, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 64, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 32, 1, 2, 1, 4, 1, 2
Offset: 1

Views

Author

Keywords

Comments

Least positive k such that m^k + 1 divides m^n + 1 (with fixed base m). - Vladimir Baltic, Mar 25 2002
To construct the sequence: start with 1, concatenate 1, 1 and double last term gives 1, 2. Concatenate those 2 terms, 1, 2, 1, 2 and double last term 1, 2, 1, 2 -> 1, 2, 1, 4. Concatenate those 4 terms: 1, 2, 1, 4, 1, 2, 1, 4 and double last term -> 1, 2, 1, 4, 1, 2, 1, 8, etc. - Benoit Cloitre, Dec 17 2002
a(n) = gcd(seq(binomial(2*n, 2*m+1)/2, m = 0 .. n - 1)) (odd numbered entries of even numbered rows of Pascal's triangle A007318 divided by 2), where gcd() denotes the greatest common divisor of a set of numbers. Due to the symmetry of the rows it suffices to consider m = 0 .. floor((n-1)/2). - Wolfdieter Lang, Jan 23 2004
Equals the continued fraction expansion of a constant x (cf. A100338) such that the continued fraction expansion of 2*x interleaves this sequence with 2's: contfrac(2*x) = [2; 1, 2, 2, 2, 1, 2, 4, 2, 1, 2, 2, 2, 1, 2, 8, 2, ...].
Simon Plouffe observes that this sequence and A003484 (Radon function) are very similar, the difference being all zeros except for every 16th term (see A101119 for nonzero differences). Dec 02 2004
This sequence arises when calculating the next odd number in a Collatz sequence: Next(x) = (3*x + 1) / A006519, or simply (3*x + 1) / BitAnd(3*x + 1, -3*x - 1). - Jim Caprioli, Feb 04 2005
a(n) = n if and only if n = 2^k. This sequence can be obtained by taking a(2^n) = 2^n in place of a(2^n) = n and using the same sequence building approach as in A001511. - Amarnath Murthy, Jul 08 2005
Also smallest m such that m + n - 1 = m XOR (n - 1); A086799(n) = a(n) + n - 1. - Reinhard Zumkeller, Feb 02 2007
Number of 1's between successive 0's in A159689. - Philippe Deléham, Apr 22 2009
Least number k such that all coefficients of k*E(n, x), the n-th Euler polynomial, are integers (cf. A144845). - Peter Luschny, Nov 13 2009
In the binary expansion of n, delete everything left of the rightmost 1 bit. - Ralf Stephan, Aug 22 2013
The equivalent sequence for partitions is A194446. - Omar E. Pol, Aug 22 2013
Also the 2-adic value of 1/n, n >= 1. See the Mahler reference, definition on p. 7. This is a non-archimedean valuation. See Mahler, p. 10. Sometimes called 2-adic absolute value of 1/n. - Wolfdieter Lang, Jun 28 2014
First 2^(k-1) - 1 terms are also the heights of the successive rectangles and squares of width 2 that are adjacent to any of the four sides of the toothpick structure of A139250 after 2^k stages, with k >= 2. For example: if k = 5 the heights after 32 stages are [1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1] respectively, the same as the first 15 terms of this sequence. - Omar E. Pol, Dec 29 2020

Examples

			2^3 divides 24, but 2^4 does not divide 24, so a(24) = 8.
2^0 divides 25, but 2^1 does not divide 25, so a(25) = 1.
2^1 divides 26, but 2^2 does not divide 26, so a(26) = 2.
Per _Marc LeBrun_'s 2000 comment, a(n) can also be determined with bitwise operations in two's complement. For example, given n = 48, we see that n in binary in an 8-bit byte is 00110000 while -n is 11010000. Then 00110000 AND 11010000 = 00010000, which is 16 in decimal, and therefore a(48) = 16.
G.f. = x + 2*x^2 + x^3 + 4*x^4 + x^5 + 2*x^6 + x^7 + 8*x^8 + x^9 + ...
		

References

  • Kurt Mahler, p-adic numbers and their functions, second ed., Cambridge University Press, 1981.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Partial sums are in A006520, second partial sums in A022560.
Sequences used in definitions of this sequence: A000079, A001511, A004198, A007814.
Sequences with related definitions: A038712, A171977, A135481 (GS(1, 6)).
This is Guy Steele's sequence GS(5, 2) (see A135416).
Related to A007913 via A225546.
A059897 is used to express relationship between sequence terms.
Cf. A091476 (Dgf at s=2).

Programs

  • Haskell
    import Data.Bits ((.&.))
    a006519 n = n .&. (-n) :: Integer
    -- Reinhard Zumkeller, Mar 11 2012, Dec 29 2011
    
  • Julia
    using IntegerSequences
    [EvenPart(n) for n in 1:102] |> println  # Peter Luschny, Sep 25 2021
    
  • Magma
    [2^Valuation(n, 2): n in [1..100]]; // Vincenzo Librandi, Mar 27 2015
    
  • Maple
    with(numtheory): for n from 1 to 200 do if n mod 2 = 1 then printf(`%d,`,1) else printf(`%d,`,2^ifactors(n)[2][1][2]) fi; od:
    A006519 := proc(n) if type(n,'odd') then 1 ; else for f in ifactors(n)[2] do if op(1,f) = 2 then return 2^op(2,f) ; end if; end do: end if; end proc: # R. J. Mathar, Oct 25 2010
    A006519 := n -> 2^padic[ordp](n,2): # Peter Luschny, Nov 26 2010
  • Mathematica
    lowestOneBit[n_] := Block[{k = 0}, While[Mod[n, 2^k] == 0, k++]; 2^(k - 1)]; Table[lowestOneBit[n], {n, 102}] (* Robert G. Wilson v Nov 17 2004 *)
    Table[2^IntegerExponent[n, 2], {n, 128}] (* Jean-François Alcover, Feb 10 2012 *)
    Table[BitAnd[BitNot[i - 1], i], {i, 1, 102}] (* Peter Luschny, Oct 10 2019 *)
  • PARI
    {a(n) = 2^valuation(n, 2)};
    
  • PARI
    a(n)=1<Joerg Arndt, Jun 10 2011
    
  • PARI
    a(n)=bitand(n,-n); \\ Joerg Arndt, Jun 10 2011
    
  • PARI
    a(n)=direuler(p=2,n,if(p==2,1/(1-2*X),1/(1-X)))[n] \\ Ralf Stephan, Mar 27 2015
    
  • Python
    def A006519(n): return n&-n # Chai Wah Wu, Jul 06 2022
  • Scala
    (1 to 128).map(Integer.lowestOneBit()) // _Alonso del Arte, Mar 04 2020
    

Formula

a(n) = n AND -n (where "AND" is bitwise, and negative numbers are represented in two's complement in a suitable bit width). - Marc LeBrun, Sep 25 2000, clarified by Alonso del Arte, Mar 16 2020
Also: a(n) = gcd(2^n, n). - Labos Elemer, Apr 22 2003
Multiplicative with a(p^e) = p^e if p = 2; 1 if p > 2. - David W. Wilson, Aug 01 2001
G.f.: Sum_{k>=0} 2^k*x^2^k/(1 - x^2^(k+1)). - Ralf Stephan, May 06 2003
Dirichlet g.f.: zeta(s)*(2^s - 1)/(2^s - 2) = zeta(s)*(1 - 2^(-s))/(1 - 2*2^(-s)). - Ralf Stephan, Jun 17 2007
a(n) = 2^floor(A002487(n - 1) / A002487(n)). - Reikku Kulon, Oct 05 2008
a(n) = 2^A007814(n). - R. J. Mathar, Oct 25 2010
a((2*k - 1)*2^e) = 2^e, k >= 1, e >= 0. - Johannes W. Meijer, Jun 07 2011
a(n) = denominator of Euler(n-1, 1). - Arkadiusz Wesolowski, Jul 12 2012
a(n) = A011782(A001511(n)). - Omar E. Pol, Sep 13 2013
a(n) = (n XOR floor(n/2)) XOR (n-1 XOR floor((n-1)/2)) = n - (n AND n-1) (where "AND" is bitwise). - Gary Detlefs, Jun 12 2014
a(n) = ((n XOR n-1)+1)/2. - Gary Detlefs, Jul 02 2014
a(n) = A171977(n)/2. - Peter Kern, Jan 04 2017
a(n) = 2^(A001511(n)-1). - Doug Bell, Jun 02 2017
a(n) = abs(A003188(n-1) - A003188(n)). - Doug Bell, Jun 02 2017
Conjecture: a(n) = (1/(A000203(2*n)/A000203(n)-2)+1)/2. - Velin Yanev, Jun 30 2017
a(n) = (n-1) o n where 'o' is the bitwise converse nonimplication. 'o' is not commutative. n o (n+1) = A135481(n). - Peter Luschny, Oct 10 2019
From Peter Munn, Dec 13 2019: (Start)
a(A225546(n)) = A225546(A007913(n)).
a(A059897(n,k)) = A059897(a(n), a(k)). (End)
Sum_{k=1..n} a(k) ~ (1/(2*log(2)))*n*log(n) + (3/4 + (gamma-1)/(2*log(2)))*n, where gamma is Euler's constant (A001620). - Amiram Eldar, Nov 15 2022
a(n) = n / A000265(n). - Amiram Eldar, May 22 2025

Extensions

More terms from James Sellers, Jun 20 2000

A228370 Toothpick sequence from a diagram of compositions of the positive integers (see Comments lines for definition).

Original entry on oeis.org

0, 1, 2, 4, 6, 7, 8, 11, 15, 16, 17, 19, 21, 22, 23, 27, 35, 36, 37, 39, 41, 42, 43, 46, 50, 51, 52, 54, 56, 57, 58, 63, 79, 80, 81, 83, 85, 86, 87, 90, 94, 95, 96, 98, 100, 101, 102, 106, 114, 115, 116, 118, 120, 121, 122, 125, 129, 130, 131, 133, 135, 136, 137, 143, 175
Offset: 0

Views

Author

Omar E. Pol, Aug 21 2013

Keywords

Comments

In order to construct this sequence we use the following rules:
We start in the first quadrant of the square grid with no toothpicks, so a(0) = 0.
If n is odd then at stage n we place the smallest possible number of toothpicks of length 1 connected by their endpoints in horizontal direction starting from the grid point (0, (n+1)/2) such that the x-coordinate of the exposed endpoint of the last toothpick is not equal to the x-coordinate of any outer corner of the structure.
If n is even then at stage n we place toothpicks of length 1 connected by their endpoints in vertical direction, starting from the exposed toothpick endpoint, downward up to touch the structure or up to touch the x-axis.
Note that the number of toothpick of added at stage (n+1)/2 in horizontal direction is also A001511(n) and the number of toothpicks added at stage n/2 in vertical direction is also A006519(n).
The sequence gives the number of toothpicks after n stages. A228371 (the first differences) gives the number of toothpicks added at the n-th stage.
After 2^k stages a new section of the structure is completed, so the structure can be interpreted as a diagram of the 2^(k-1) compositions of k in colexicographic order, if k >= 1 (see A228525). The infinite diagram can be interpreted as a table of compositions of the positive integers.
The equivalent sequence for partitions is A225600.

Examples

			For n = 32 the diagram represents the 16 compositions of 5. The structure has 79 toothpicks, so a(32) = 79. Note that the k-th horizontal line segment has length A001511(k) equals the largest part of the k-th region, and the k-th vertical line segment has length A006519(k) equals the number of parts of the k-th region.
----------------------------------------------------------
.                                    Triangle
Compositions                  of compositions (rows)
of 5          Diagram          and regions (columns)
----------------------------------------------------------
.            _ _ _ _ _
5            _        |                                 5
1+4          _|_      |                               1 4
2+3          _  |     |                             2   3
1+1+3        _|_|_    |                           1 1   3
3+2          _    |   |                         3       2
1+2+2        _|_  |   |                       1 2       2
2+1+2        _  | |   |                     2   1       2
1+1+1+2      _|_|_|_  |                   1 1   1       2
4+1          _      | |                 4               1
1+3+1        _|_    | |               1 3               1
2+2+1        _  |   | |             2   2               1
1+1+2+1      _|_|_  | |           1 1   2               1
3+1+1        _    | | |         3       1               1
1+2+1+1      _|_  | | |       1 2       1               1
2+1+1+1      _  | | | |     2   1       1               1
1+1+1+1+1     | | | | |   1 1   1       1               1
.
Illustration of initial terms (n = 1..16):
.
.                                   _        _
.                   _ _    _ _      _ _      _|_
.       _     _     _      _  |     _  |     _  |
.              |     |      | |      | |      | |
.
.       1      2     4      6        7        8
.
.
.                                            _ _
.                        _         _         _
.     _ _ _    _ _ _     _ _ _     _|_ _     _|_ _
.     _        _    |    _    |    _    |    _    |
.     _|_      _|_  |    _|_  |    _|_  |    _|_  |
.     _  |     _  | |    _  | |    _  | |    _  | |
.      | |      | | |     | | |     | | |     | | |
.
.       11       15        16        17        19
.
.
.                                _ _ _ _    _ _ _ _
.             _        _         _          _      |
.    _ _      _ _      _|_       _|_        _|_    |
.    _  |     _  |     _  |      _  |       _  |   |
.    _|_|_    _|_|_    _|_|_     _|_|_      _|_|_  |
.    _    |   _    |   _    |    _    |     _    | |
.    _|_  |   _|_  |   _|_  |    _|_  |     _|_  | |
.    _  | |   _  | |   _  | |    _  | |     _  | | |
.     | | |    | | |    | | |     | | |      | | | |
.
.      21       22       23        27          35
.
		

Crossrefs

Programs

  • Python
    def A228370(n): return sum(((m:=(i>>1)+1)&-m).bit_length() if i&1 else (m:=i>>1)&-m for i in range(1,n+1)) # Chai Wah Wu, Jul 14 2022

Formula

a(n) = sum_{k=1..n} A228371(k), n >= 1.
a(2n-1) = A005187(n) + A006520(n+1) - A006519(n), n >= 1.
a(2n) = A005187(n) + A006520(n+1), n >= 1.

A022560 a(0)=0, a(2*n) = 2*a(n) + 2*a(n-1) + n^2 + n, a(2*n+1) = 4*a(n) + (n+1)^2.

Original entry on oeis.org

0, 1, 4, 8, 16, 25, 36, 48, 68, 89, 112, 136, 164, 193, 224, 256, 304, 353, 404, 456, 512, 569, 628, 688, 756, 825, 896, 968, 1044, 1121, 1200, 1280, 1392, 1505, 1620, 1736, 1856, 1977, 2100, 2224, 2356, 2489, 2624, 2760, 2900, 3041
Offset: 0

Views

Author

Andre Kundgen (kundgen(AT)math.uiuc.edu)

Keywords

Crossrefs

First differences are in A006520.
Cf. A070263.

Programs

  • Mathematica
    a[n_]:= If[n==0, 0, If[Mod[n, 2]==0, 2*a[n/2] + 2*a[n/2-1] +(n/2)^2 +(n/2), 4*a[(n-1)/2] +((n+1)/2)^2]]; Table[a[n], {n, 0, 50}] (* G. C. Greubel, Feb 26 2018 *)
  • PARI
    a(n) = if (n==0, 0, if (n % 2, my(nn = (n-1)/2); 4*a(nn)+(nn+1)^2, my(nn = n/2); 2*a(nn)+2*a(nn-1)+nn^2+nn)) \\ Michel Marcus, Jun 27 2013
    
  • Sage
    def a(n):
        if (n==0): return 0
        elif (n%2==0): return 2*a(n/2) + 2*a(n/2 -1) +(n/2)^2 +(n/2)
        else: return 4*a((n-1)/2) +((n+1)/2)^2
    [a(n) for n in (0..50)] # G. C. Greubel, Jun 13 2019

Formula

Let a(i, n) = 2^(i-1)*floor(1/2 + n/2^i); sequence is a(n) = Sum_{i=1} a(i, n)*(n - a(i, n)).
Second differences give A006519.
Also a(1)=0 and a(n) = floor(n^2/4) + a(floor(n/2)) + a(ceiling(n/2)).
G.f.: 1/(1-x)^2 * (x/(1-x) + Sum_{k>=1} 2^(k-1)*x^2^k/(1-x^2^k)). - Ralf Stephan, Apr 17 2003
a(0)=0, a(2n) = 2*a(n) + 2*a(n-1) + n^2 + n, a(2n+1) = 4a(n)+(n+1)^2. - Ralf Stephan, Sep 13 2003

Extensions

More terms from Ralf Stephan, Sep 13 2003

A340619 n appears A006519(n) times.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Jan 13 2021

Keywords

Comments

This sequence has similarities with the Cantor staircase function.
This sequence can be seen as an irregular table where the n-th row contains A006519(n) times the value n.
For any k > 1, the set of points { (n, a(n)), n = 1..A006520(2^k-1) } is symmetric; for example, for k = 3, we have the following configuration:
a(n)
^
| *
| **
| *
| ****
| *
| **
|*
+-------------> n

Examples

			The first rows, alongside A006519(n), are:
    n | n-th row               | A006519(n)
   ---+------------------------+-----------
    1 | 1                      |          1
    2 | 2, 2                   |          2
    3 | 3                      |          1
    4 | 4, 4, 4, 4             |          4
    5 | 5                      |          1
    6 | 6, 6                   |          2
    7 | 7                      |          1
    8 | 8, 8, 8, 8, 8, 8, 8, 8 |          8
    9 | 9                      |          1
   10 | 10, 10                 |          2
		

Crossrefs

See A061392 and A340500 for similar sequences.

Programs

  • Mathematica
    A340619[n_] := Array[n &, Table[BitAnd[BitNot[i - 1], i], {i, 1, n}][[n]]];
    Table[A340619[n], {n, 1, 26}] // Flatten (* Robert P. P. McKone, Jan 19 2021 *)
  • PARI
    concat(apply(v -> vector(2^valuation(v,2), k, v), [1..26]))
    
  • PARI
    a(n) = my(ret=0); forstep(k=logint(n,2),0,-1, if(n > k<<(k-1), ret+=1<Kevin Ryde, Jan 18 2021

Formula

a(A006520(n)) = n.
a(A006520(n)+1) = n+1.
a(n) + a(A006520(2^k-1) + 1 - n) = 2^k for any k > 0 and n = 1..A006520(2^k-1).
a(n) = 2^k + (a(r) if r>0), where k such that k*2^(k-1) < n <= (k+1)*2^k and r = n - (k+2)*2^(k-1). - Kevin Ryde, Jan 18 2021

A348556 Binary expansion contains 4 adjacent 1's.

Original entry on oeis.org

15, 30, 31, 47, 60, 61, 62, 63, 79, 94, 95, 111, 120, 121, 122, 123, 124, 125, 126, 127, 143, 158, 159, 175, 188, 189, 190, 191, 207, 222, 223, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 271, 286, 287, 303, 316, 317, 318
Offset: 1

Views

Author

Keywords

Comments

For k > 0, each term m = 2^(k+3) - 1 is the end of a run of A083593(k-1) consecutive terms. For k = 4, from a(13) = 120 up to a(20) = 2^7-1 = 127, there are A083593(3) = 8 consecutive terms corresponding to 1111000, 1111001, 1111010, 1111011, 1111100, 1111101, 111110 and 1111111. - Bernard Schott, Feb 20 2022

Crossrefs

Binary expansion contains k adjacent 1s: A000027 (1), A004780 (2), A004781 (3), this sequence (4).
Subsequences: A110286, A195744.

Programs

  • Maple
    q:= n-> verify([1$4], Bits[Split](n), 'sublist'):
    select(q, [$0..400])[];  # Alois P. Heinz, Oct 22 2021
  • Mathematica
    Select[Range[300], StringContainsQ[IntegerString[#, 2], "1111"] &] (* Amiram Eldar, Oct 22 2021 *)
  • PARI
    is(n)=n=bitand(n,n<<2); !!bitand(n,n<<1);
    
  • Python
    def ok(n): return "1111" in bin(n)
    print([k for k in range(319) if ok(k)]) # Michael S. Branicky, Oct 22 2021

Formula

a(n) ~ n.
a(n+1) <= a(n) + 16.

A368595 Alternating sum of A006519.

Original entry on oeis.org

-1, 1, 0, 4, 3, 5, 4, 12, 11, 13, 12, 16, 15, 17, 16, 32, 31, 33, 32, 36, 35, 37, 36, 44, 43, 45, 44, 48, 47, 49, 48, 80, 79, 81, 80, 84, 83, 85, 84, 92, 91, 93, 92, 96, 95, 97, 96, 112, 111, 113, 112, 116, 115, 117, 116, 124, 123, 125, 124, 128, 127, 129, 128
Offset: 1

Views

Author

Jeffrey Shallit, Dec 31 2023

Keywords

Comments

a(n) <= (n/2)*log_2 n, with equality at powers of 2.

Crossrefs

Cf. A006519. A006520 (all positive signs), A136013.
Cf. A093347 (with powers of 3).

Programs

  • Mathematica
    a[1]=-1;a[n_]:=If[OddQ[n],a[n-1]-2^IntegerExponent[n,2],a[n-1]+2^IntegerExponent[n,2]];Table[a[n],{n,63}] (* James C. McMahon, Dec 31 2023 *)
  • PARI
    a(n) = fromdigits(Vec(Pol(binary(n))'),2) - bitand(n,1); \\ Kevin Ryde, Jan 01 2024
    
  • Python
    def A368595(n): return sum(map(lambda x:(x[0]+1)*(1<Chai Wah Wu, Jan 01 2024

Formula

a(n) = Sum_{i=1..n} (-1)^i*A006519(i).
a(n) = A136013(n) - (n mod 2). - Kevin Ryde, Jan 01 2024

A326300 Steinhaus sums.

Original entry on oeis.org

2, 6, 8, 16, 18, 22, 24, 40, 42, 46, 48, 56, 58, 62, 64, 96, 98, 102, 104, 112, 114, 118, 120, 136, 138, 142, 144, 152, 154, 158, 160, 224, 226, 230, 232, 240, 242, 246, 248, 264, 266, 270, 272, 280, 282, 286, 288, 320, 322, 326, 328, 336, 338, 342, 344, 360, 362, 366, 368
Offset: 1

Views

Author

Michel Marcus, Oct 17 2019

Keywords

Crossrefs

Cf. A000523 (log_2(n)), A006520.

Programs

  • PARI
    a(n) = sum(k=1, 1+log(n)\log(2), floor(n/2^k+1/2)*2^k);
    
  • Python
    def a(n):
        s = 0
        for k in range(1,n.bit_length()+1):
            s += ((n + (1 << (k-1))) >> k) << k
        return s
    print([a(n) for n in range(1,60)]) # Darío Clavijo, Aug 24 2024

Formula

a(n) = Sum_{k>=1} floor(n/2^k + 1/2)*2^k.
a(n) = 2 * A006520(n-1).
Showing 1-7 of 7 results.