login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A080079 Least number causing the longest carry sequence when adding numbers <= n to n in binary representation. 21
1, 2, 1, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 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, 1, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

COMMENTS

T(n,k) < T(n,a(n)) = A070940(n) for 1 <= k < a(n) and T(n,k) <= T(n,a(n)) for a(n) <= k <= n, where T is defined as in A080080.

a(n) gives the distance from n to the nearest 2^t > n. - Ctibor O. Zizka, Apr 09 2020

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 1..10000

Index entries for sequences related to binary expansion of n

FORMULA

From Benoit Cloitre, Feb 22 2003: (Start)

a(n) = A004755(n) - 2*n.

a(n) = -n + 2*2^floor(log(n)/log(2)). (End)

From Ralf Stephan, Jun 02 2003: (Start)

a(n) = n iff n = 2^k, otherwise a(n) = A035327(n-1).

a(n) = A062383(n) - n. (End)

a(0) = 0, a(2*n) = 2*a(n), a(2*n+1) = 2*a(n)-1 + 2*[n==0]. - Ralf Stephan, Jan 04 2004

a(n) = A240769(n,1); A240769(n, a(n)) = 1. - Reinhard Zumkeller, Apr 13 2014

a(n) = n + 1 - A006257(n). - Reinhard Zumkeller, Apr 14 2014

MAPLE

# Alois P. Heinz observes in A327489:

A080079 := n -> 1 + Bits:-Nor(n, n):

# Likewise:

A080079 := n -> 1 + Bits:-Nand(n, n):

seq(A080079(n), n=1..81); # Peter Luschny, Sep 23 2019

MATHEMATICA

Flatten@Table[Nest[Most[RotateRight[#]] &, Range[n], n - 1], {n, 30}] (* Birkas Gyorgy, Feb 07 2011 *)

Table[FromDigits[(IntegerDigits[n, 2] /. {0 -> 1, 1 -> 0}), 2] +

1, {n, 30}] (* Birkas Gyorgy, Feb 07 2011 *)

Table[BitXor[n, 2^IntegerPart[Log[2, n] + 1] - 1] + 1, {n, 30}] (* Birkas Gyorgy, Feb 07 2011 *)

Table[2 2^Floor[Log[2, n]] - n, {n, 30}] (* Birkas Gyorgy, Feb 07 2011 *)

Flatten@Table[Reverse@Range[2^n], {n, 0, 4}] (* Birkas Gyorgy, Feb 07 2011 *)

PROG

(Haskell)

a080079 n = (length $ takeWhile (< a070940 n) (a080080_row n)) + 1

-- Reinhard Zumkeller, Apr 22 2013

(MAGMA) [-n+2*2^Floor(Log(n)/Log(2)): n in [1..80]]; // Vincenzo Librandi, Dec 01 2016

CROSSREFS

Cf. A327489, A004755, A062383, A080080, A240769, A006257.

Sequence in context: A281589 A302436 A283167 * A341707 A318569 A336280

Adjacent sequences:  A080076 A080077 A080078 * A080080 A080081 A080082

KEYWORD

nonn,base

AUTHOR

Reinhard Zumkeller, Jan 26 2003

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 8 13:59 EST 2021. Contains 341949 sequences. (Running on oeis4.)