OFFSET
0,2
COMMENTS
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..8192
FORMULA
a(n) = 2 * A051382(n).
EXAMPLE
2, which in base 3 is also '2', satisfies the condition, thus it is included;
4, which in base 3 is '11', is included;
6, which in base 3 is '20', is included;
8, which in base 3 is '22', is included;
12, which in base 3 is '110', is included;
14, which in base 3 is '112', is included;
however, e.g., 13, 40, and 130, whose ternary representations are '111', '1111' and '11211' respectively, are not included, because they all contain more than one pair of 1's.
PROG
(Scheme, with Antti Karttunen's IntSeq-library)
(define (in_A249721? n) (let loop ((n n) (seen11yet? #f)) (cond ((zero? n) #t) ((= 2 n) #t) ((modulo n 3) => (lambda (r) (let ((next_n (/ (- n r) 3))) (cond ((= r 1) (if (or seen11yet? (not (= 1 (modulo next_n 3)))) #f (loop (/ (- next_n 1) 3) #t))) (else (loop next_n seen11yet?)))))))))
;; Or alternatively, based on code for A051382:
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Nov 14 2014
STATUS
approved