This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A051382 #37 Feb 16 2025 08:32:41 %S A051382 0,1,2,3,4,6,7,9,10,11,12,13,18,19,21,22,27,28,29,30,31,33,34,36,37, %T A051382 38,39,40,54,55,57,58,63,64,66,67,81,82,83,84,85,87,88,90,91,92,93,94, %U A051382 99,100,102,103,108,109,110,111,112,114,115,117,118,119,120,121,162,163 %N A051382 Numbers k whose base 3 expansion matches (0|1)*(02)?(0|1)* (no more than one "02" allowed in midst of 0's and 1's). %C A051382 Representation of 2n in base 3 consists entirely of 0's and 2's, except possibly for a single pair of adjacent 1's among them. %C A051382 9 divides neither C(2s-1,s) [= A001700(s)] nor C(2s,s) [= A000984(s)] if and only if s = a(n). [Cf. also A249721]. %H A051382 Alois P. Heinz, <a href="/A051382/b051382.txt">Table of n, a(n) for n = 1..32768</a> (first 8193 terms from Antti Karttunen) %H A051382 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/BinomialCoefficient.html">Binomial Coefficient</a> %H A051382 <a href="/index/Ar#3-automatic">Index entries for 3-automatic sequences</a>. %e A051382 In base 3 the terms look like 0, 1, 2, 10, 11, 20, 21, 100, 101, 102, 110, 111, 200, 201, 210, 211, 1000, 1001, 1002, 1010, 1011, 1020, 1021, 1100, 1101, 1102, 1110, 1111, 2000, 2001, 2010, 2011, 2100, 2101, 2 110, 2111, 10000 %p A051382 q:= n-> (l-> (h-> h=0 or h=1 and l[1+ListTools[Search](2, l)] %p A051382 =0 )(numboccur(l, 2)))([convert(n, base, 3)[], 0]): %p A051382 select(q, [$0..163])[]; # _Alois P. Heinz_, Jun 28 2021 %o A051382 (Perl) sub conv_x_base_n { my($x, $b) = @_; my ($r, $z) = (0, ''); do { $r = $x % $b; $x = ($x - $r)/$b; $z = "$r" . $z; } while(0 != $x); return($z); } %o A051382 (Perl) for($i=1; $i <= 201; $i++) { if(("0" . conv_x_base_n($i, 3)) =~ /^(0|1)*(02)?(0|1)*$/) { print $i, ", "; } } %o A051382 (Scheme, with _Antti Karttunen_'s IntSeq-library) %o A051382 (define A051382 (MATCHING-POS 0 0 in_A051382?)) %o A051382 (define (in_A051382? n) (let loop ((n n) (seen02yet? #f)) (cond ((zero? n) #t) ((= 1 n) #t) ((modulo n 3) => (lambda (r) (cond ((= r 2) (if (or seen02yet? (not (zero? (modulo (/ (- n r) 3) 3)))) #f (loop (/ (- n r) 3) #t))) (else (loop (/ (- n r) 3) seen02yet?)))))))) %o A051382 (Python) %o A051382 import re %o A051382 from sympy.ntheory.digits import digits %o A051382 def b3(n): return "".join(map(str, digits(n, 3)[1:])) %o A051382 def ok(n): return re.fullmatch('2(0|1)*|(0|1)*(02)?(0|1)*', b3(n)) != None %o A051382 print(list(filter(ok, range(164)))) # _Michael S. Branicky_, Jun 26 2021 %o A051382 (PARI) is(n)=my(v=digits(n,3)); for(i=1,#v, if(v[i]==2, if(i>1 && v[i-1], return(0)); for(j=i+1,#v, if(v[j]==2, return(0))); return(1))); 1 \\ _Charles R Greathouse IV_, Feb 23 2024 %Y A051382 Complement: A249719. %Y A051382 Terms of A249721 halved. %Y A051382 Cf. A046097, A048645, A037468, A005836, A117966, A249720. %K A051382 nonn,base,easy %O A051382 1,3 %A A051382 _David W. Wilson_, _Antti Karttunen_, Oct 24 1999 %E A051382 a(0) = 0 prepended as a border-line case by _Antti Karttunen_, Nov 14 2014 %E A051382 Offset changed to 1 by _Georg Fischer_, Jun 28 2021