%I #17 Mar 02 2020 19:35:16
%S 1,11,10,11,101,110,1001,1111,100,101,11111,110,111,1001,1010,11011,
%T 10011,1100,100011,1111,10010,111001,100101,11110,110001,111111,1000,
%U 1001,1011011,1010,1011,100111,111110,1011111,101101,1100,1101
%N Least positive multiple of n written in base 3 using only 0 and 1.
%H Robert Israel, <a href="/A004283/b004283.txt">Table of n, a(n) for n = 1..10000</a>
%p h:= proc(n)
%p option remember;
%p local t,x;
%p t:= n mod 3;
%p if t = 2 then -1
%p else
%p x:= procname((n-t)/3);
%p if x = -1 then -1
%p else 10*x + t
%p fi
%p fi
%p end proc:
%p h(0):= 0:
%p h(1):= 1:
%p A004283:= proc(n) local k,r;
%p for k from 1 do
%p r:= h(k*n);
%p if r <> -1 then return r fi
%p od
%p end proc:
%p seq(A004283(n),n=1..100); # _Robert Israel_, Dec 26 2015
%t lpm3[n_]:=Module[{k=1},While[DigitCount[k*n,3,2]>0,k++];FromDigits[ IntegerDigits[ k*n,3]]]; Array[lpm3,40] (* _Harvey P. Dale_, Mar 02 2020 *)
%o (PARI) a(n) = {k=1; while (vecmax(digits(k*n, 3)) != 1, k++); subst(Pol(digits(k*n, 3)), x, 10);} \\ _Michel Marcus_, Dec 27 2015
%Y Cf. A005836.
%K nonn,base
%O 1,2
%A _David W. Wilson_
%E a(34) corrected by _Sean A. Irvine_, Dec 26 2015
|