%I #21 Jul 30 2022 20:09:36
%S 0,1,5,16400,16401,16405,82000,82001,82005
%N Numbers whose base-4 and base-5 representations have only 0's and 1's.
%C Intersection of A000695 and A033042.
%C These appear to be all the terms. There are no more below 10^500.
%e 16400 is 10000100 in base 4 and 1011100 in base 5.
%p split:= proc(ab, B)
%p local a,b,La, Lb, k, j, a1, a2, b1, b2, x;
%p global Res, count;
%p a:= ab[1]; b:= ab[2];
%p if b-a <= 1000 then
%p for x from a to b-1 do
%p if max(convert(x,base,4)) <= 1 and max(convert(x,base,5)) <= 1 then
%p count:= count+1; Res[count]:= x
%p fi
%p od;
%p return ({});
%p fi;
%p La:= convert(a,base,B);
%p Lb:= convert(b,base,B);
%p if nops(Lb) > nops(La) then La:= [op(La),0$(nops(Lb)-nops(La))] fi;
%p k:= ListTools:-SelectLast(`>`,Lb-La,0,output=indices);
%p if La[k] = 0 then
%p a1:= a;
%p b1:= 2 + add(B^i,i=1..k-2) + add(La[i]*B^(i-1),i=k+1..nops(La));
%p a2:= B^(k-1) + add(La[i]*B^(i-1),i=k+1..nops(La));
%p b2:= min(b, b1 + B^(k-1));
%p return(select(t -> (t[1]<t[2]),{[a1,b1],[a2,b2]}));
%p elif La[k] = 1 then
%p a1:= a;
%p b1:= 2 + add(B^i,i=1..k-2) + add(La[i]*B^(i-1),i=k..nops(La));
%p return(select(t -> t[1]<t[2], [[a1,b1]]))
%p else return ( {})
%p fi;
%p end proc:
%p count:= 0: Res:= 'Res':
%p Cands:= {[0,10^400]}:
%p while nops(Cands) > 0 do
%p Cands:= map(op@split, Cands, 5);
%p Cands:= map(op@split, Cands, 4);
%p od:
%p sort(convert(Res,list));
%t Select[Range[0,83000],Max[Join[IntegerDigits[#,4],IntegerDigits[#,5]]]<2&] (* _Harvey P. Dale_, Sep 04 2018 *)
%o (PARI) isok(n) = (n==0) || ((vecmax(digits(n,4))<=1) && (vecmax(digits(n,5))<=1)); \\ _Michel Marcus_, Oct 24 2015
%Y Cf. A000695, A033042, A146025, A258981.
%K nonn,fini,full
%O 1,3
%A _Robert Israel_, Oct 23 2015
|