login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A072219 Any number n can be written uniquely in the form n = 2^k_1 - 2^k_2 + 2^k_3 - ... + 2^k_{2r+1} where the signs alternate, there are an odd number of terms, and k_1 > k_2 > k_3 > ... > k_{2r+1} >= 0; sequence gives number of terms 2r+1. 10

%I #35 Sep 03 2023 08:41:45

%S 1,1,3,1,3,3,3,1,3,3,5,3,3,3,3,1,3,3,5,3,5,5,5,3,3,3,5,3,3,3,3,1,3,3,

%T 5,3,5,5,5,3,5,5,7,5,5,5,5,3,3,3,5,3,5,5,5,3,3,3,5,3,3,3,3,1,3,3,5,3,

%U 5,5,5,3,5,5,7,5,5,5,5,3,5,5,7,5,7,7,7,5,5,5,7,5,5,5,5,3,3,3,5,3,5,5,5,3,5

%N Any number n can be written uniquely in the form n = 2^k_1 - 2^k_2 + 2^k_3 - ... + 2^k_{2r+1} where the signs alternate, there are an odd number of terms, and k_1 > k_2 > k_3 > ... > k_{2r+1} >= 0; sequence gives number of terms 2r+1.

%C 2^k_1 is smallest power of 2 that is >= n.

%C The first Mathematica program computes the sequence for numbers 1 to 2^m. - _T. D. Noe_, Jul 15 2002

%C a(A000079(n)) = 1; a(A238246(n)) = 3; a(A238247(n)) = 5; a(A238248(n)) = 7. - _Reinhard Zumkeller_, Feb 20 2014

%C Add 1 to every other terms of A005811. - _N. J. A. Sloane_, Jan 14 2017

%D P. Bachmann, Niedere Zahlentheorie (1902, 1910), reprinted Chelsea, NY, 1968, vol. 2, pp. 61-62.

%H Reinhard Zumkeller, <a href="/A072219/b072219.txt">Table of n, a(n) for n = 1..16384</a>

%H S. Kropf and S. Wagner, <a href="https://arxiv.org/abs/1605.03654">q-Quasiadditive functions</a>, arXiv:1605.03654 [math.CO], 2016. See section "The number of runs and the Gray code".

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F G.f.: 1/(1+x) + (1/(1-x)) * Sum_{r>=0} x^(2^r) / (1+x^(2^(r+1))). - _Ramasamy Chandramouli_, Dec 22 2012

%e 1=1, 2=2, 3=4-2+1, 4=4, 5=8-4+1, 6=8-4+2, ...

%t Needs["DiscreteMath`Combinatorica`"]; sumit[s_List] := Module[{i, ss=0}, Do[If[OddQ[i], ss+=s[[i]], ss-=s[[i]]], {i, Length[s]}]; ss]; m=8; powers=Table[2^i, {i, 0, m}]; lst=Table[0, {2^m}]; sets={}; Do[sets=Union[sets, KSubsets[powers, i]], {i, 1, m+1, 2}]; Do[t=sets[[i]]; lst[[sumit[t]]]=Length[t], {i, Length[sets]}]; lst

%t (* second program *)

%t a[n_] := 2 Count[Split[IntegerDigits[n-1, 2], #1 == 1 && #2 == 0 &], {1, 0} ] + 1; Array[a, 105] (* _Jean-François Alcover_, Apr 01 2016 *)

%o (Haskell)

%o a072219 = (+ 1) . (* 2) . a033264 . subtract 1

%o -- _Reinhard Zumkeller_, Feb 20 2014

%Y Cf. A000079, A005811, A030308, A072339, A065621, A238246, A238247, A238248.

%Y Equals 2*A033264(n-1) + 1.

%K nonn,easy,nice

%O 1,3

%A _N. J. A. Sloane_, Jul 05 2002

%E More terms from _T. D. Noe_, Jul 15 2002

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 08:33 EDT 2024. Contains 371905 sequences. (Running on oeis4.)