|
|
A003817
|
|
a(0) = 0, a(n) = a(n-1) OR n.
|
|
28
|
|
|
0, 1, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15, 15, 15, 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, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
Also, 0+1+2+...+n in lunar arithmetic in base 2 written in base 10. - N. J. A. Sloane, Oct 02 2010
For n>0: replace all 0's with 1's in binary representation of n. - Reinhard Zumkeller, Jul 14 2003
|
|
LINKS
|
D. Applegate, M. LeBrun and N. J. A. Sloane, Dismal Arithmetic, arXiv:1107.1130 [math.NT], 2011. [Note: we have now changed the name from "dismal arithmetic" to "lunar arithmetic" - the old name was too depressing]
|
|
FORMULA
|
a(n) = a(n-1) + n*(1-floor(a(n-1)/n)). If 2^(k-1) <= n < 2^k, a(n) = 2^k - 1. - Benoit Cloitre, Aug 25 2002
G.f.: (1/(1-x)) * Sum_{k>=0} 2^k*x^2^k. - Ralf Stephan, Apr 18 2003
G.f. A(x) satisfies: A(x) = 2*A(x^2)*(1 + x) + x/(1 - x). - Ilya Gutkovskiy, Aug 31 2019
|
|
MAPLE
|
A003817 := n -> n + Bits:-Nand(n, n):
|
|
MATHEMATICA
|
a[0] = 0; a[n_] := a[n] = BitOr[ a[n-1], n]; Table[a[n], {n, 0, 61}] (* Jean-François Alcover, Dec 19 2011 *)
nxt[{n_, a_}]:={n+1, BitOr[a, n+1]}; Transpose[NestList[nxt, {0, 0}, 70]] [[2]] (* Harvey P. Dale, May 06 2016 *)
2^BitLength[Range[0, 100]]-1 (* Paolo Xausa, Feb 08 2024 *)
|
|
PROG
|
(Haskell)
import Data.Bits ((.|.))
a003817 n = if n == 0 then 0 else 2 * a053644 n - 1
a003817_list = scanl (.|.) 0 [1..] :: [Integer]
(Python)
def a(n): return 0 if n==0 else 1 + 2*a(int(n/2)) # Indranil Ghosh, Apr 28 2017
|
|
CROSSREFS
|
This is Guy Steele's sequence GS(6, 6) (see A135416).
|
|
KEYWORD
|
nonn,base,nice
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|