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.

A117971 One-based position of the first 2 from the least significant digit in the ternary expansion of 2^n, or 0 if there are no 2's present.

This page as a plain text file.
%I A117971 #19 Feb 16 2025 08:33:00
%S A117971 0,1,0,1,2,1,4,1,0,1,2,1,3,1,3,1,2,1,5,1,8,1,2,1,11,1,11,1,2,1,3,1,3,
%T A117971 1,2,1,4,1,4,1,2,1,5,1,4,1,2,1,3,1,3,1,2,1,6,1,8,1,2,1,4,1,7,1,2,1,3,
%U A117971 1,3,1,2,1,12,1,7,1,2,1,6,1,10,1,2,1,3,1,3,1,2,1,4,1,4,1,2,1,6,1,4,1,2,1,3,1
%N A117971 One-based position of the first 2 from the least significant digit in the ternary expansion of 2^n, or 0 if there are no 2's present.
%C A117971 a(0), a(2) and a(8) are the conjectured to be the only terms equal to 0.
%H A117971 Antti Karttunen, <a href="/A117971/b117971.txt">Table of n, a(n) for n = 0..16384</a>
%H A117971 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Ternary.html">Ternary</a>
%e A117971 For n=0, 2^0 = 1 is also "1" in base-3, thus there are no 2-digits present, and therefore a(0) = 0.
%e A117971 For n=4, 2^4 = 16, which in base-3 is "121" as 1*(3^2) + 2*3 + 1 = 16, so the rightmost 2 occurs at two steps from the end, therefore a(4) = 2.
%e A117971 For n=5, 2^5 = 32, which in base-3 is "1012" as 1*(3^3) + 1*3 + 2*1 = 32, so the rightmost 2 occurs as the least significant digit (which is the position 1), therefore a(5) = 1.
%t A117971 pf2[n_]:=Module[{p=Position[Reverse[IntegerDigits[2^n,3]],2,{1},1]},If[p=={},0,p]]; Flatten[Array[pf2,110]] (* _Harvey P. Dale_, Nov 30 2013 *)
%o A117971 (PARI) A117971(n) = { my(n=(2^n),i=1); while(n, if(2==(n%3),return(i)); i++; n \= 3); (0); }; \\ _Antti Karttunen_, Mar 30 2021
%Y A117971 Cf. A004642 (ternary expansion of 2^n), A007089. See also A117970.
%K A117971 nonn,base
%O A117971 0,5
%A A117971 _Eric W. Weisstein_, Apr 06 2006
%E A117971 Edited by _Charles R Greathouse IV_, Aug 05 2010
%E A117971 Term a(0) = 0 prepended, examples added and the definition clarified by _Antti Karttunen_, Mar 30 2021