OFFSET
1,2
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000 (first 70 terms from Vincenzo Librandi)
Vaclav Kotesovec, Graph - the asymptotic ratio (600000 terms).
FORMULA
The characteristic function of this sequence is given by Sum_{n >= 1} x^a(n) = Sum_{n >= 1} mu(21*n)*x^n/(1 - x^n), where mu(n) is the Möbius function A008683. Cf. with the formula of Hanna in A051037. - Peter Bala, Mar 18 2019
Sum_{n>=1} 1/a(n) = (3*7)/((3-1)*(7-1)) = 7/4. - Amiram Eldar, Sep 22 2020
a(n) ~ exp(sqrt(2*log(3)*log(7)*n)) / sqrt(21). - Vaclav Kotesovec, Sep 22 2020
MATHEMATICA
f[upto_]:=Sort[Select[Flatten[3^First[#] 7^Last[#] & /@ Tuples[{Range[0, Floor[Log[3, upto]]], Range[0, Floor[Log[7, upto]]]}]], # <= upto &]]; f[120000] (* Harvey P. Dale, Mar 04 2011 *)
fQ[n_] := PowerMod[21, n, n] == 0; Select[Range[120000], fQ] (* Bruno Berselli, Sep 24 2012 *)
PROG
(PARI) list(lim)=my(v=List(), N); for(n=0, log(lim)\log(7), N=7^n; while(N<=lim, listput(v, N); N*=3)); vecsort(Vec(v)) \\ Charles R Greathouse IV, Jun 28 2011
(Magma) [n: n in [1..120000] | PrimeDivisors(n) subset [3, 7]]; // Bruno Berselli, Sep 24 2012
(Haskell)
import Data.Set (singleton, deleteFindMin, insert)
a003594 n = a003594_list !! (n-1)
a003594_list = f $ singleton 1 where
f s = y : f (insert (3 * y) $ insert (7 * y) s')
where (y, s') = deleteFindMin s
-- Reinhard Zumkeller, May 16 2015
(GAP) Filtered([1..120000], n->PowerMod(21, n, n)=0); # Muniru A Asiru, Mar 19 2019
(Python)
from sympy import integer_log
def A003594(n):
def bisection(f, kmin=0, kmax=1):
while f(kmax) > kmax: kmax <<= 1
while kmax-kmin > 1:
kmid = kmax+kmin>>1
if f(kmid) <= kmid:
kmax = kmid
else:
kmin = kmid
return kmax
def f(x): return n+x-sum(integer_log(x//7**i, 3)[0]+1 for i in range(integer_log(x, 7)[0]+1))
return bisection(f, n, n) # Chai Wah Wu, Sep 16 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved