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.

A103185 a(n) = Sum_{ k >= 0 such that n + k == 0 mod 2^k } 2^(k-1).

Original entry on oeis.org

0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 2, 1, 8, 5, 2, 1, 0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 2, 17, 8, 5, 2, 1, 0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 2, 1, 8, 5, 2, 1, 0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 34, 17, 8, 5, 2, 1, 0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 2, 1, 8, 5, 2, 1, 0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 2, 17, 8, 5, 2, 1, 0, 1, 2, 1, 0, 5, 2, 1
Offset: 0

Views

Author

N. J. A. Sloane, Mar 18 2005

Keywords

Crossrefs

Cf. A102370(n).

Programs

  • Mathematica
    f[n_] := Block[{k = 1, s = 0, l = Max[2, Floor[ Log[2, n + 1] + 2]]}, While[k < l, If[ Mod[n + k, 2^k] == 0, s = s + 2^(k - 1)]; k++ ]; s]; Table[ f[n], {n, 0, 103}] (* Robert G. Wilson v, Mar 18 2005 *)
  • PARI
    A103185(n)=(sum(k=0,ceil(log(n+1)/log(2)),if((n+k)%2^k,0,2^k))-1)/2 \\ Benoit Cloitre, Mar 20 2005
    
  • Python
    def a102370(n): return 0 if n<1 else sum([(n + k)&(2**k) for k in range(len(bin(n)[2:]) + 1)])
    def a(n): return (a102370(n) - n)/2 # Indranil Ghosh, May 03 2017

Formula

a(n) = (A102370(n) - n)/2.

Extensions

More terms from Robert G. Wilson v, Mar 18 2005