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
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) = 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
(Python)
def A080079(n): return (1 << n.bit_length())-n # Chai Wah Wu, Jun 30 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Reinhard Zumkeller, Jan 26 2003
STATUS
approved