OFFSET
1,2
COMMENTS
For any a(n) == 0 (mod 3), 3*a(n)+1 and 3*a(n)+2 are also in the sequence, but 3*a(n) is not. Likewise, for any a(n) == 2 (mod 3) -- except for a(2)=2 -- 3*a(n) and 3*a(n)+1 are in the sequence but 3*a(n)+2 is not. - Christian N. K. Anderson, May 21 2024
LINKS
Christian N. K. Anderson, Table of n, a(n) for n = 1..10000
EXAMPLE
The numbers {415, 416, 424, 425, 428, 451, 452, 455} are in the sequence because in base 3 they are {120101, 120102, 120201, 120202, 120212, 121201, 121202, 121212}; all the six-digit base-3 numbers that fit the pattern. - Christian N. K. Anderson, May 21 2024
PROG
(R)
updown.base<-function(base, ndig, curdig=1, diglist=rep(NA, ndig)) {
if(curdig>ndig) return(sum(base^(ndig:1-1)*diglist)); nextstep<-function(i) {diglist[curdig]=i; updown.base(base, ndig, curdig+1, diglist)}; if(curdig==1) return(sort(unlist(sapply(1:(base-2+(ndig==1)), nextstep)))); if(curdig%%2) return(sapply((diglist[curdig-1]-1):0, nextstep)); sapply((diglist[curdig-1]+1):(base-1), nextstep) }; sapply(1:10, function(nd) updown.base(3, nd)) # Christian N. K. Anderson, May 21 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
STATUS
approved