A039276 Numbers whose base-3 representation has the same nonzero number of 0's and 2's.
6, 11, 15, 19, 21, 32, 34, 38, 42, 46, 48, 56, 58, 60, 64, 66, 72, 89, 95, 97, 101, 103, 105, 113, 115, 119, 123, 127, 129, 137, 139, 141, 145, 147, 153, 167, 169, 173, 175, 177, 181, 183, 191, 193, 195, 199, 201, 207, 217, 219, 225, 260, 266, 268, 278, 284
Offset: 1
Programs
-
Mathematica
Select[Range[300],DigitCount[#,3,0]==DigitCount[#,3,2]>0&] (* Harvey P. Dale, May 10 2011 *)
-
Python
from sympy.ntheory import count_digits def ok(n): d = count_digits(n, 3); return 0 in d and 2 in d and d[0] == d[2] print(list(filter(ok, range(285)))) # Michael S. Branicky, Jun 11 2021