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.
%I A139351 #45 May 07 2025 00:49:25 %S A139351 0,1,0,1,1,2,1,2,0,1,0,1,1,2,1,2,1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,0,1, %T A139351 0,1,1,2,1,2,0,1,0,1,1,2,1,2,1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,1,2,1,2, %U A139351 2,3,2,3,1,2,1,2,2,3,2,3,2,3,2,3,3,4,3,4,2,3,2,3,3,4,3,4,1,2,1 %N A139351 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence gives e(n). %C A139351 e(n)+o(n) = A000120(n), the binary weight of n. %C A139351 a(n) is also number of 1's and 3's in 4-ary representation of n. - _Frank Ruskey_, May 02 2009 %H A139351 Reinhard Zumkeller, <a href="/A139351/b139351.txt">Table of n, a(n) for n = 0..10000</a> %H A139351 Franklin T. Adams-Watters and Frank Ruskey, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL12/Ruskey2/ruskey14.html">Generating Functions for the Digital Sum and Other Digit Counting Sequences</a>, JIS 12 (2009), Article 09.5.6. %H A139351 N. J. A. Sloane, <a href="/A139351/a139351.f.txt">Fortran program for this and related sequences</a>. %F A139351 a(n) + A139352(n) = A000120(n). %F A139351 G.f.: (1/(1-z))*Sum_{m>=0} (z^(4^m)/(1+z^(4^m))). - _Frank Ruskey_, May 03 2009 %F A139351 Recurrence relation: a(0)=0, a(4m) = a(4m+2) = a(m), a(4m+1) = a(4m+3) = 1+a(m). - _Frank Ruskey_, May 11 2009 %F A139351 a(n) = Sum_{k} A030308(n,k)*A059841(k). - _Philippe Deléham_, Oct 14 2011 %e A139351 For n = 43 = 2^0 + 2^1 + 2^3 + 2^5, e(43)=1, o(43)=3. %p A139351 A139351 := proc(n) %p A139351 local a,bdgs,r; %p A139351 a := 0 ; %p A139351 bdgs := convert(n,base,2) ; %p A139351 for r from 1 to nops(bdgs) by 2 do %p A139351 if op(r,bdgs) = 1 then %p A139351 a := a+1 ; %p A139351 end if; %p A139351 end do: %p A139351 a; %p A139351 end proc: # _R. J. Mathar_, Jul 21 2016 %t A139351 terms = 99; s = (1/(1-z))*Sum[z^(4^m)/(1+z^(4^m)), {m, 0, Log[4, terms] // Ceiling}] + O[z]^terms; CoefficientList[s, z] (* _Jean-François Alcover_, Jul 21 2017 *) %t A139351 a[0] = 0; a[n_] := a[n] = a[Floor[n/4]] + If[OddQ[Mod[n, 4]], 1, 0]; Array[a, 100, 0] (* _Amiram Eldar_, Jul 18 2023 *) %o A139351 (Fortran) See Sloane link. %o A139351 (Haskell) %o A139351 import Data.List (unfoldr) %o A139351 a139351 = sum . map (`mod` 2) . %o A139351 unfoldr (\x -> if x == 0 then Nothing else Just (x, x `div` 4)) %o A139351 -- _Reinhard Zumkeller_, Apr 22 2011 %o A139351 (PARI) a(n)=if(n>3,a(n\4))+n%2 \\ _Charles R Greathouse IV_, Apr 21 2016 %Y A139351 Cf. A000120, A030308, A059841, A139352, A139353, A139354, A139355, A039004, A139370, A139371, A139372, A139373. %K A139351 nonn,base,easy %O A139351 0,6 %A A139351 _Nadia Heninger_ and _N. J. A. Sloane_, Jun 07 2008 %E A139351 Typo in example fixed by _Reinhard Zumkeller_, Apr 22 2011