OFFSET
1,1
COMMENTS
Terms are reduced, i.e., ternary codes do not have trailing zeros.
The term is a digitized Motzkin path that starts with an up step and ends with a down step. Such a path has neither leading nor final flat steps, i.e., the ternary code of the corresponding term has no finite 0's. Recall that in ternary code, 1's are up steps, and 2's are down steps.
LINKS
Gennady Eremin, Table of n, a(n) for n = 1..1000
Kurt Mahler, The representation of squares to the base 3, Acta Arith. Vol. 53, Issue 1 (1989), p. 105.
PROG
(Python)
def digits(n, b):
out = []
while n >= b:
out.append(n % b)
n //= b
return [n] + out[::-1]
def ok(n):
if n%3 == 0: return False
t = digits(n, 3)
if t.count(1) != t.count(2): return False
return all(t[:i].count(1) >= t[:i].count(2) for i in range(1, len(t)))
print([n for n in range(750) if ok(n)]) # after Michael S. Branicky (A340131)
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Gennady Eremin, Jan 11 2021
STATUS
approved