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 10 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

A135416 a(n) = A036987(n)*(n+1)/2.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Comments

Guy Steele defines a family of 36 integer sequences, denoted here by GS(i,j) for 1 <= i, j <= 6, as follows. a[1]=1; a[2n] = i-th term of {0,1,a[n],a[n]+1,2a[n],2a[n]+1}; a[2n+1] = j-th term of {0,1,a[n],a[n]+1,2a[n],2a[n]+1}. The present sequence is GS(1,5).
The full list of 36 sequences:
GS(1,1) = A000007
GS(1,2) = A000035
GS(1,3) = A036987
GS(1,4) = A007814
GS(1,5) = A135416 (the present sequence)
GS(1,6) = A135481
GS(2,1) = A135528
GS(2,2) = A000012
GS(2,3) = A000012
GS(2,4) = A091090
GS(2,5) = A135517
GS(2,6) = A135521
GS(3,1) = A036987
GS(3,2) = A000012
GS(3,3) = A000012
GS(3,4) = A000120
GS(3,5) = A048896
GS(3,6) = A038573
GS(4,1) = A135523
GS(4,2) = A001511
GS(4,3) = A008687
GS(4,4) = A070939
GS(4,5) = A135529
GS(4,6) = A135533
GS(5,1) = A048298
GS(5,2) = A006519
GS(5,3) = A080100
GS(5,4) = A087808
GS(5,5) = A053644
GS(5,6) = A000027
GS(6,1) = A135534
GS(6,2) = A038712
GS(6,3) = A135540
GS(6,4) = A135542
GS(6,5) = A054429
GS(6,6) = A003817
(with a(0)=1): Moebius transform of A038712.

Crossrefs

Equals A048298(n+1)/2. Cf. A036987, A182660.

Programs

  • Maple
    GS:=proc(i,j,M) local a,n; a:=array(1..2*M+1); a[1]:=1;
    for n from 1 to M do
    a[2*n] :=[0,1,a[n],a[n]+1,2*a[n],2*a[n]+1][i];
    a[2*n+1]:=[0,1,a[n],a[n]+1,2*a[n],2*a[n]+1][j];
    od: a:=convert(a,list); RETURN(a); end;
    GS(1,5,200):
  • Mathematica
    i = 1; j = 5; Clear[a]; a[1] = 1; a[n_?EvenQ] := a[n] = {0, 1, a[n/2], a[n/2]+1, 2*a[n/2], 2*a[n/2]+1}[[i]]; a[n_?OddQ] := a[n] = {0, 1, a[(n-1)/2], a[(n-1)/2]+1, 2*a[(n-1)/2], 2*a[(n-1)/2]+1}[[j]]; Array[a, 105] (* Jean-François Alcover, Sep 12 2013 *)
  • PARI
    A048298(n) = if(!n,0,if(!bitand(n,n-1),n,0));
    A135416(n) = (A048298(n+1)/2); \\ Antti Karttunen, Jul 22 2018
    
  • Python
    def A135416(n): return int(not(n&(n+1)))*(n+1)>>1 # Chai Wah Wu, Jul 06 2022

Formula

G.f.: sum{k>=1, 2^(k-1)*x^(2^k-1) }.
Recurrence: a(2n+1) = 2a(n), a(2n) = 0, starting a(1) = 1.

Extensions

Formulae and comments by Ralf Stephan, Jun 20 2014

A136013 a(n) = floor(n/2) + 2*a(floor(n/2)), a(0) = 0.

Original entry on oeis.org

0, 0, 1, 1, 4, 4, 5, 5, 12, 12, 13, 13, 16, 16, 17, 17, 32, 32, 33, 33, 36, 36, 37, 37, 44, 44, 45, 45, 48, 48, 49, 49, 80, 80, 81, 81, 84, 84, 85, 85, 92, 92, 93, 93, 96, 96, 97, 97, 112, 112, 113, 113, 116, 116, 117, 117, 124, 124, 125, 125, 128
Offset: 0

Views

Author

Jack Preston (jpreston(AT)earthlink.net), Mar 20 2008

Keywords

Comments

A recursive sequence that seems to be related to the ruler function.
It seems that a(2n) = a(2n+1) = A080277(n). - Emeric Deutsch, Mar 31 2008
It appears that if the binary expansion of n is n = Sum b_i*2^i (b_i=0 or 1), then a(n) = Sum i*b_i*2^(i-1). - Marc LeBrun, Sep 07 2015
The observations in the preceding two comments (by Emeric Deutsch and Marc LeBrun) follow from the formulas in A333979. - Pontus von Brömssen, Sep 06 2020
This sequence is a variant of the arithmetic derivative (A003415) based on powers of two instead of primes, because the relation a(m*n) = m*a(n) + n*a(m) holds. If we define the polynomial P(2) = bit0*2^0 + bit1*2^1 + bit2*2^2 + ... = n, and P'(2) is the derivative of P(2), then we will observe P'(2) = a(n). - Thomas Scheuerle, Aug 02 2022

Crossrefs

Cf. A080277, A003415, A333979, A135481 (first differences).

Programs

  • Maple
    a:=proc(n) if n=0 then 0 else floor((1/2)*n)+2*a(floor((1/2)*n)) end if end proc: seq(a(n),n=0..60); # Emeric Deutsch, Mar 31 2008
  • Mathematica
    a = {0}; Do[AppendTo[a, Floor[n/2] + 2*a[[Floor[n/2] + 1]]], {n, 1, 100}]; a (* Stefan Steinerberger, Mar 24 2008 *)
    Table[Sum[2^(k-1)*Floor[n*2^-k], {k, 1, Log[2, n]}], {n, 0, 100}] (* Federico Provvedi, Aug 17 2013 *)
  • PARI
    a(n) = fromdigits(Vec(Pol(binary(n))'),2); \\ Kevin Ryde, Apr 29 2021
    
  • Python
    def A136013(n): return sum(map(lambda x:(x[0]+1)*(1<Chai Wah Wu, Jul 06 2022

Formula

a(n) = A333979(n,2). - Pontus von Brömssen, Sep 06 2020

Extensions

More terms from Stefan Steinerberger and Emeric Deutsch, Mar 24 2008
Spelling corrected by Jason G. Wurtzel, Aug 30 2010

A140670 a(n) = 1 if n is odd; otherwise, a(n) = 2^k - 1 where 2^k is the largest power of 2 that divides n.

Original entry on oeis.org

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

Views

Author

Michael Somos, May 21 2008

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := If[OddQ[n], 1, 2^IntegerExponent[n, 2] - 1]; Array[a, 100] (* Amiram Eldar, Oct 22 2022 *)
  • PARI
    {a(n) = if(n==0, 0, if(n%2, 1, 2^valuation(n, 2) - 1))}
    
  • Python
    def A140670(n): return max(1,(n&-n)-1) # Chai Wah Wu, Jul 08 2022

Formula

a(n) is multiplicative with a(2^e) = 2^e - 1 if e > 0, a(p^e) = 1 if p > 2.
a(2*n + 1) = 1. a(-n) = a(n). a(2*n) = 2 * a(n) + (-1)^n unless n=0.
Dirichlet g.f.: zeta(s)*(1+2^(1-2s)-2^(1-s))/(1-2^(1-s)). - R. J. Mathar, Feb 07 2011
a(n) = (2*A160467(n))-1. - Antti Karttunen, Nov 18 2017
Sum_{k=1..n} a(k) ~ (1/(2*log(2))) * (n*log(n) + (gamma + log(2)/2 - 1) * n), where gamma is Euler's constant (A001620). - Amiram Eldar, Oct 22 2022
a(n) = A006519(n) - A059841(n). - Ridouane Oudra, Jul 30 2025

A328568 Irregular triangle read by rows; for n >= 0, the n-th row corresponds to the elements of the set {(n-k) XOR k, k = 0..n}, in ascending order (where XOR denotes the bitwise XOR operator).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Oct 20 2019

Keywords

Comments

For any n >= 0, the n-th row:
- has sum A328565(n),
- has apparently length A002487(n+1),
- has first element A135481(n),
- has last element n.

Examples

			Table begins:
    0;
    1;
    0, 2;
    3;
    0, 2, 4;
    1, 5;
    0, 4, 6;
    7;
    0, 4, 6, 8;
    1, 5, 9;
    0, 2, 4, 8, 10;
    3, 11;
    0, 2, 8, 10, 12;
    1, 9, 13;
    0, 8, 12, 14;
    ...
		

Crossrefs

Cf. A326819 (AND variant), A326820 (OR variant).

Programs

  • Maple
    T:= n-> sort([{seq(Bits[Xor](n-k, k), k=0..n)}[]])[]:
    seq(T(n), n=0..30);  # Alois P. Heinz, Oct 20 2019
  • Mathematica
    Union /@ Table[BitXor[n - k, k], {n, 0, 22}, {k, 0, n}] // Flatten (* George Beck, Jun 09 2023 *)
  • PARI
    row(n) = Set(apply(k -> bitxor(n-k, k), [0..n]))

A342410 The binary expansion of a(n) corresponds to that of n where all the 1's have been replaced by 0's except in the last run of 1's.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Apr 25 2021

Keywords

Comments

In other words, this sequence gives the last run of 1's in the binary expansion of a number.

Examples

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

Crossrefs

Programs

  • Mathematica
    Array[FromDigits[If[Length[s=Split@IntegerDigits[#,2]]>1,Flatten[s[[-2;;]]],First@s],2]&,100,0] (* Giorgos Kalogeropoulos, Apr 27 2021 *)
  • PARI
    a(n) = { if (n, my (z=valuation(n, 2), o=valuation(n/2^z+1, 2)); (2^o-1)*2^z, 0) }
    
  • Python
    def A342410(n):
        if n == 0 : return 0
        for i, d in enumerate(bin(n)[2:].split('0')[::-1]):
            if d != '': return int(d+'0'*i,2) # Chai Wah Wu, Apr 29 2021

Formula

a(2*n) = 2*a(n).
a(a(n)) = a(n).
a(n) <= n with equality iff n belongs to A023758.

A331739 a(n) is n minus its largest odd divisor.

Original entry on oeis.org

0, 1, 0, 3, 0, 3, 0, 7, 0, 5, 0, 9, 0, 7, 0, 15, 0, 9, 0, 15, 0, 11, 0, 21, 0, 13, 0, 21, 0, 15, 0, 31, 0, 17, 0, 27, 0, 19, 0, 35, 0, 21, 0, 33, 0, 23, 0, 45, 0, 25, 0, 39, 0, 27, 0, 49, 0, 29, 0, 45, 0, 31, 0, 63, 0, 33, 0, 51, 0, 35, 0, 63, 0, 37, 0, 57, 0, 39, 0, 75, 0, 41, 0, 63, 0, 43, 0, 77, 0, 45, 0, 69, 0, 47
Offset: 1

Views

Author

Antti Karttunen, Feb 02 2020

Keywords

Crossrefs

Cf. A129527 (even bisection).

Programs

Formula

a(n) = n - A000265(n).
Sum_{k=1..n} a(k) ~ n^2/6. - Amiram Eldar, Sep 13 2024

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)))).

A342639 Square array T(n, k), n, k >= 0, read by antidiagonals; T(n, k) = g(f(n) + f(k)) where g maps the complement, say s, of a finite set of nonnegative integers to the value Sum_{e >= 0 not in s} 2^e, f is the inverse of g, and "+" denotes the Minkowski sum.

Original entry on oeis.org

0, 1, 1, 0, 3, 0, 3, 1, 1, 3, 0, 7, 2, 7, 0, 1, 1, 3, 3, 1, 1, 0, 3, 0, 15, 0, 3, 0, 7, 1, 5, 3, 3, 5, 1, 7, 0, 15, 2, 7, 0, 7, 2, 15, 0, 1, 1, 7, 3, 1, 1, 3, 7, 1, 1, 0, 3, 0, 31, 4, 11, 4, 31, 0, 3, 0, 3, 1, 1, 3, 7, 5, 5, 7, 3, 1, 1, 3, 0, 7, 2, 7, 0, 15, 6, 15, 0, 7, 2, 7, 0
Offset: 0

Views

Author

Rémy Sigrist, Mar 17 2021

Keywords

Comments

In other words:
- we consider the set S of sets s of nonnegative integers whose complement is finite,
- the function g encodes the "missing integers" in binary:
g(A001477 \ {1, 4}) = 2^1 + 2^4 = 18
- the function f is the inverse of g:
f(42) = f(2^1 + 2^3 + 2^5) = A001477 \ {1, 3, 5},
- the Minkowski sum of two sets, say U and V, is the set of sums u+v where u belongs to U and v belongs to V,
- the Minkowski sum is stable over S,
- and T provides an encoding for this operation.
This sequence has connections with A067138; here we consider complements of finite sets of nonnegative integers, there finite sets of nonnegative integers.

Examples

			Array T(n, k) begins:
  n\k|   0   1   2   3   4   5   6    7   8   9  10  11  12  13  14   15
  ---+------------------------------------------------------------------
    0|   0   1   0   3   0   1   0    7   0   1   0   3   0   1   0   15
    1|   1   3   1   7   1   3   1   15   1   3   1   7   1   3   1   31
    2|   0   1   2   3   0   5   2    7   0   1   2  11   0   5   2   15
    3|   3   7   3  15   3   7   3   31   3   7   3  15   3   7   3   63
    4|   0   1   0   3   0   1   4    7   0   1   0   3   0   9   4   15
    5|   1   3   5   7   1  11   5   15   1   3   5  23   1  11   5   31
    6|   0   1   2   3   4   5   6    7   0   9   2  11   4  13   6   15
    7|   7  15   7  31   7  15   7   63   7  15   7  31   7  15   7  127
    8|   0   1   0   3   0   1   0    7   0   1   0   3   0   1   8   15
    9|   1   3   1   7   1   3   9   15   1   3   1   7   1  19   9   31
   10|   0   1   2   3   0   5   2    7   0   1  10  11   0   5  10   15
   11|   3   7  11  15   3  23  11   31   3   7  11  47   3  23  11   63
   12|   0   1   0   3   0   1   4    7   0   1   0   3   8   9  12   15
   13|   1   3   5   7   9  11  13   15   1  19   5  23   9  27  13   31
   14|   0   1   2   3   4   5   6    7   8   9  10  11  12  13  14   15
   15|  15  31  15  63  15  31  15  127  15  31  15  63  15  31  15  255
		

Crossrefs

Programs

  • PARI
    T(n,k) = { my (v=0); for (x=0, #binary(n)+#binary(k), my (f=0); for (y=0, x, if (!bittest(n,y) && !bittest(k,x-y), f=1; break)); if (!f, v+=2^x)); return (v) }

Formula

T(n, k) = T(k, n).
T(m, T(n, k)) = T(T(m, n), k).
T(n, 0) = A135481(n).
T(n, 1) = A038712(n+1).
T(2^n-1, 2^k-1) = 2^(n+k)-1.
T(n, n) = A342640(n).

A355223 The k-th rightmost digit of a(n) is the least of the k rightmost digits of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Jun 24 2022

Keywords

Comments

Leading zeros are ignored.

Examples

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

Crossrefs

See A355221, A355222 and A355224 for similar sequences.
Cf. A008592, A009994 (fixed points), A135481 (binary analog).

Programs

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

Formula

a(n) <= n with equality iff n belongs to A009994.
a(a(n)) = a(n).
a(n) = 0 iff n is a multiple of 10.
Showing 1-10 of 10 results.