login
a(n) = 1 + floor(n/(1-log(2)/log(3))).
10

%I #54 Oct 10 2024 08:17:21

%S 1,3,6,9,11,14,17,19,22,25,28,30,33,36,38,41,44,47,49,52,55,57,60,63,

%T 66,68,71,74,76,79,82,84,87,90,93,95,98,101,103,106,109,112,114,117,

%U 120,122,125,128,131,133,136,139,141,144,147,150,152,155,158,160,163

%N a(n) = 1 + floor(n/(1-log(2)/log(3))).

%C These numbers appear in connection with the 3x+1 problem.

%C Also, numbers n such that the first digit in ternary expansion on 2^n is 2. _N. J. A. Sloane_ conjectured that, for any integer n >=15, 2^n always has a 0 in its ternary expansion. - Mohammed Bouayoun (Mohammed.bouayoun(AT)sanef.com), Apr 24 2006

%C Except for 1, this is the complement of A020914 and therefore these two form a pair of Beatty sequences. - _Robert G. Wilson v_, May 25 2014

%F a(n) = 1 + floor(n * r), with r = log(3) / log(3/2) = 2.709511... - _Ruud H.G. van Tol_, May 09 2024

%e a(5) = 1 + floor(5/(1-log(2)/log(3)))= 1 + floor(5/0.3690702464...)= 1 + floor(13.54...) = 14.

%p Digits := 500: it := evalf(ln(2)/ln(3)): for n from 0 to 200 do printf(`%d,`,1+floor(n/(1-it))) od:

%t Do[If[First[IntegerDigits[2^n, 3]] == 2, Print[n]], {n, 1, 200}] (* Mohammed Bouayoun (Mohammed.bouayoun(AT)sanef.com), Apr 24 2006 *)

%t f[n_]:=Floor[1+n/(1-(Log[2]/Log[3]))];Array[f,105] (* _Robert G. Wilson v_, May 25 2014 *)

%o (PARI) alist(N) = my(a=1/2, b=1, r=-1); vector(N, i, a*=4; b*=3; r+=2; if(a>b, a*=2; b*=3; r++); r); \\ _Ruud H.G. van Tol_, Jan 21 2024 (with help from the pari-users mailing list)

%o (Python)

%o from operator import sub

%o from sympy import integer_log

%o def A054414(n):

%o if n == 0: return 1

%o def f(x): return n+sub(*integer_log(1<<x,3))+1

%o m, k = n, f(n)

%o while m != k: m, k = k, f(k)

%o return m # _Chai Wah Wu_, Oct 09 2024

%o (Python) # faster for initial segment of sequence

%o from itertools import islice

%o def agen(): # generator of terms, after _Ruud H.G. van Tol_

%o a, b, r = 2, 3, 1

%o while True:

%o yield r

%o a <<= 2; b *= 3; r += 2

%o if a > b: a <<= 1; b *= 3; r += 1

%o print(list(islice(agen(), 100))) # _Michael S. Branicky_, Oct 10 2024

%Y Cf. A020914.

%K easy,nonn

%O 0,2

%A B. Schaaf (m.m.schaaf-visch(AT)wxs.nl), May 20 2000

%E More terms from _James A. Sellers_, May 23 2000

%E Erroneous formula a(n) =? A083088(n) + n - 1 deleted Jan 30 2008