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.

A062756 Number of 1's in ternary (base-3) expansion of n.

This page as a plain text file.
%I A062756 #63 Dec 10 2023 11:10:27
%S A062756 0,1,0,1,2,1,0,1,0,1,2,1,2,3,2,1,2,1,0,1,0,1,2,1,0,1,0,1,2,1,2,3,2,1,
%T A062756 2,1,2,3,2,3,4,3,2,3,2,1,2,1,2,3,2,1,2,1,0,1,0,1,2,1,0,1,0,1,2,1,2,3,
%U A062756 2,1,2,1,0,1,0,1,2,1,0,1,0,1,2,1,2,3,2,1,2,1,2,3,2,3,4,3,2,3,2,1,2,1,2,3,2
%N A062756 Number of 1's in ternary (base-3) expansion of n.
%C A062756 Fixed point of the morphism: 0 ->010; 1 ->121; 2 ->232; ...; n -> n(n+1)n, starting from a(0)=0. - _Philippe Deléham_, Oct 25 2011
%H A062756 Reinhard Zumkeller, <a href="/A062756/b062756.txt">Table of n, a(n) for n = 0..10000</a>
%H A062756 F. T. Adams-Watters and F. 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) 09.5.6.
%H A062756 Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>
%H A062756 S. Northshield, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Northshield/north4.html">An Analogue of Stern's Sequence for Z[sqrt(2)]</a>, Journal of Integer Sequences, 18 (2015), #15.11.6.
%H A062756 Kevin Ryde, <a href="http://user42.tuxfamily.org/terdragon/index.html">Iterations of the Terdragon Curve</a>, see index "dir".
%H A062756 Robert Walker, <a href="http://robertinventor.com/ftswiki/Self_Similar_Sloth_Canon_Number_Sequences">Self Similar Sloth Canon Number Sequences</a>
%F A062756 a(0) = 0, a(3n) = a(n), a(3n+1) = a(n)+1, a(3n+2) = a(n). - _Vladeta Jovovic_, Jul 18 2001
%F A062756 G.f.: (Sum_{k>=0} x^(3^k)/(1+x^(3^k)+x^(2*3^k)))/(1-x). In general, the generating function for the number of digits equal to d in the base b representation of n (0 < d < b) is (Sum_{k>=0} x^(d*b^k)/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x). - _Franklin T. Adams-Watters_, Nov 03 2005 [For d=0, use the above formula with d=b: (Sum_{k>=0} x^(b^(k+1))/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x), adding 1 if you consider the representation of 0 to have one zero digit.]
%F A062756 a(n) = a(floor(n/3)) + (n mod 3) mod 2. - _Paul D. Hanna_, Feb 24 2006
%t A062756 Table[Count[IntegerDigits[i, 3], 1], {i, 0, 200}]
%t A062756 Nest[Join[#, # + 1, #] &, {0}, 5] (* _IWABUCHI Yu(u)ki_, Sep 08 2012 *)
%o A062756 (PARI) a(n)=if(n<1,0,a(n\3)+(n%3)%2) \\ _Paul D. Hanna_, Feb 24 2006
%o A062756 (PARI) a(n)=hammingweight(digits(n,3)%2); \\ _Ruud H.G. van Tol_, Dec 10 2023
%o A062756 (Haskell)
%o A062756 a062756 0 = 0
%o A062756 a062756 n = a062756 n' + m `mod` 2 where (n',m) = divMod n 3
%o A062756 -- _Reinhard Zumkeller_, Feb 21 2013
%o A062756 (Python)
%o A062756 from sympy.ntheory import digits
%o A062756 def A062756(n): return digits(n,3)[1:].count(1) # _Chai Wah Wu_, Dec 23 2022
%Y A062756 Cf. A080846, A343785 (first differences).
%Y A062756 Cf. A081606 (indices of !=0).
%Y A062756 Indices of terms 0..6: A005823, A023692, A023693, A023694, A023695, A023696, A023697.
%Y A062756 Numbers of: A077267 (0's), A081603 (2's), A160384 (1's+2's).
%Y A062756 Other bases: A000120, A160381, A268643.
%K A062756 nonn,base
%O A062756 0,5
%A A062756 Ahmed Fares (ahmedfares(AT)my-deja.com), Jul 16 2001
%E A062756 More terms from _Vladeta Jovovic_, Jul 18 2001