%I #37 Apr 17 2020 07:19:33
%S 0,1,2,6,36,37,260,1302,1376,1380,1381,1382,1556,1560,1561,1562,16932,
%T 562500,562501,562502,562506,562512,562536,562537,562752,562760,
%U 23610752,23610756,23610757,23610786,23615750,23615760,23615761,23615762,23615785,23615786,23626310
%N Numbers that can be written in all bases from base 2 to base 6 using only the digits 0, 1 and 2.
%C Is there any number that keeps this property also in base 7, other than the trivial cases 0,1,2?
%H Rémy Sigrist and Chai Wah Wu, <a href="/A275600/b275600.txt">Table of n, a(n) for n = 1..10000</a> [Terms 1 through 187 by Chai Wah Wu]
%e 16932 is in the sequence because this number can be written in bases 2 through 6 using only the digits 0, 1 and 2: 16932(b4) = 10020210 / (b5) = 1020212 / (b6) = 210220.
%t Select[Range[10^6], Function[k, Max@ Flatten@ Map[IntegerDigits[k, #] &, Range[4, 6]] < 3]] (* or *)
%t Select[Range[10^5], Function[k, Total@ Flatten@ Map[Take[RotateRight@ DigitCount[k, #], -(# - 3)] &, Range[4, 6]] == 0]] (* (not as efficient) _Michael De Vlieger_, Aug 03 2016 *)
%o (Python) from gmpy2 import digits
%o A275600_list = [n for n in (int(digits(m,3),6) for m in range(10**6)) if max(digits(n,5)) <= '2' and max(digits(n,4)) <= '2'] # _Chai Wah Wu_, Aug 15 2016
%o (Perl) use ntheory ":all"; my($x,$n10)=(0,0); while ($x < 50) { my $n = fromdigits( todigitstring($n10++, 3), 6); next if vecany { $_ > 2 } todigits($n, 4); next if vecany { $_ > 2 } todigits($n, 5); print ++$x," $n\n"; } # _Dana Jacobsen_, Aug 16 2016
%o (PARI) nextWithSmallDigits(n, base) = my (pow=1, rem=n, val=0, d); while (rem>0, d = rem % base; rem = rem \ base; if (d>2, val = 0; rem = rem+1, val = val + d*pow); pow = pow * base); return (val)
%o { n = 0; prev = 0; while (n < 300, succ = prev; for (b=4,6, succ = nextWithSmallDigits(succ, b)); if (prev==succ, n = n+1; print(n " " prev); prev = succ+1, prev = succ)) } \\ _Rémy Sigrist_, Sep 08 2016
%Y Cf. A146025, A146026, A146027, A146028, A146029, A258107, A258981.
%K nonn,base
%O 1,3
%A _Sergio Pimentel_, Aug 03 2016
%E a(18)-a(26) from _Michael De Vlieger_, Aug 03 2016
%E a(27)-a(37) from _Chai Wah Wu_, Aug 15 2016