OFFSET
0,4
COMMENTS
a(n) is the greatest ternary repunit that is not greater than the n-th number with no 2 in ternary representation.
FORMULA
EXAMPLE
MATHEMATICA
With[{nn=5}, Flatten[Table[#[[1]], {#[[2]]}]&/@Thread[{Table[FromDigits[ PadRight[{}, n, 1], 3], {n, nn}], 2^Range[nn]}]]] (* Harvey P. Dale, Jan 04 2013 *)
PROG
(PARI) apply( {A107680(n)=3^exponent(n+1)\2}, [0..66]) \\ M. F. Hasler, Jun 22 2020
(Python)
def A107680(n): return 3**((n+1).bit_length()-1)-1>>1 # Chai Wah Wu, Nov 07 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, May 20 2005
EXTENSIONS
Corrected by T. D. Noe, Oct 25 2006
Extended to a(0) = 0 by M. F. Hasler, Jun 23 2020
STATUS
approved