%I #22 Jun 28 2025 09:52:44
%S 1,3,9,11,13,19,31,33,39,91,93,99,111,113,119,131,133,139,191,193,199,
%T 311,313,319,331,333,339,391,393,399,911,913,919,931,933,939,991,993,
%U 999,1111,1113,1119,1131,1133,1139,1191,1193,1199,1311,1313,1319,1331
%N a(n) = number whose product of digits equals a power of 3.
%C Equivalently, numbers whose decimal representation consists of digits from the set {1,3,9}.
%H Reinhard Zumkeller, <a href="/A174813/b174813.txt">Table of n, a(n) for n = 1..10000</a>
%e a(9)=39 is in the sequence because 3*9=3^3.
%t Select[Range[2000], IntegerQ[Log[3, Times @@ (IntegerDigits[#])]] &]
%o (Haskell)
%o a174813 n = a174813_list !! (n-1)
%o a174813_list = f [1] where
%o f ds = foldr (\d v -> 10 * v + d) 0 ds : f (s ds)
%o s [] = [1]; s (9:ds) = 1 : s ds; s (d:ds) = 3*d : ds
%o -- _Reinhard Zumkeller_, Jan 13 2014
%o (Python)
%o from sympy import integer_log
%o def A174813(n):
%o m = integer_log(k:=(n<<1)+1,3)[0]
%o return sum(3**((k-3**m)//(3**j<<1)%3)*10**j for j in range(m)) # _Chai Wah Wu_, Jun 28 2025
%Y Cf. A028846, A061427.
%K nonn,base
%O 1,2
%A _Michel Lagneau_, Dec 01 2010