login
Sort the numbers 2^i and 3^j. Then a(n) is the exponent of the n-th term.
5

%I #14 Feb 05 2025 01:49:05

%S 0,1,1,2,3,2,4,3,5,6,4,7,5,8,9,6,10,11,7,12,8,13,14,9,15,10,16,17,11,

%T 18,19,12,20,13,21,22,14,23,15,24,25,16,26,17,27,28,18,29,30,19,31,20,

%U 32,33,21,34,22,35,36,23,37,38,24,39,25,40,41,26,42,27,43,44,28

%N Sort the numbers 2^i and 3^j. Then a(n) is the exponent of the n-th term.

%C A006899(n) = A085239(n)^a(n);

%C a(A085240(n))=a(n).

%H T. D. Noe, <a href="/A085238/b085238.txt">Table of n, a(n) for n = 1..500</a>

%o (Haskell)

%o a085238 n = e (mod x 2 + 2) x where

%o x = a006899 n

%o e b p = if p == 1 then 0 else 1 + e b (p `div` b)

%o -- _Reinhard Zumkeller_, Oct 09 2013

%o (PARI) do(lim)=my(v=List(vector(logint(lim\=1,2),i,1<<i))); for(i=0,logint(lim,3), listput(v,3^i)); apply(n->my(t=valuation(n,2)); if(t, t, valuation(n,3)), Set(v)) \\ _Charles R Greathouse IV_, Sep 02 2015

%o (Python)

%o from sympy import integer_log

%o def A085238(n): return k+1 if 6**(k:=integer_log(m:=3**(n-1),6)[0])<<1<m else integer_log(1<<n,6)[0] # _Chai Wah Wu_, Feb 04 2025

%K nonn

%O 1,4

%A _Reinhard Zumkeller_, Jun 22 2003