cp's OEIS Frontend

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.

A004290 Least positive multiple of n that when written in base 10 uses only 0's and 1's.

This page as a plain text file.
%I A004290 #119 Aug 01 2025 20:56:03
%S A004290 1,10,111,100,10,1110,1001,1000,111111111,10,11,11100,1001,10010,1110,
%T A004290 10000,11101,1111111110,11001,100,10101,110,110101,111000,100,10010,
%U A004290 1101111111,100100,1101101,1110,111011,100000,111111,111010
%N A004290 Least positive multiple of n that when written in base 10 uses only 0's and 1's.
%C A004290 It is easy to show that a(n) always exists and in fact has at most n digits [Wu, 2014]. - _N. J. A. Sloane_, Jun 13 2014
%C A004290 a(n) = min{A007088(k): k > 0 and A007088(k) mod n = 0}. - _Reinhard Zumkeller_, Jan 10 2012
%C A004290 a(10^k) = 10^k and a(10^k - 1) = (10^(9k) - 1) / 9 for all k. Is a(n) < a(10^k - 1) for all n < 10^k - 1? - _David Radcliffe_, Aug 01 2025
%H A004290 Chai Wah Wu, <a href="/A004290/b004290.txt">Table of n, a(n) for n = 1..9998</a> (first 2000 terms from T. D. Noe [and Ed Pegg Link])
%H A004290 Ed Pegg Jr., <a href="https://www.mathpuzzle.com/Binary.html">'Binary' Puzzle</a>.
%H A004290 Eric M. Schmidt, <a href="/A004290/a004290_1.sage.txt">Sage code to compute this sequence</a>.
%H A004290 Chai Wah Wu, <a href="https://www.jstor.org/stable/10.4169/amer.math.monthly.121.06.529">Pigeonholes and repunits</a>, Amer. Math. Monthly, 121 (2014), 529-533.
%F A004290 a(n) = n*A079339(n). - _Jonathan Sondow_, Jun 15 2014
%p A004290 f:= proc(n)
%p A004290 local L,x,m,r,k,j;
%p A004290 if n<2 then return n fi;
%p A004290 for x from 2 to n-1 do L[0,x]:= 0 od:
%p A004290 L[0,0]:= 1: L[0,1]:= 1;
%p A004290 for m from 1 do
%p A004290    if L[m-1,(-10^m) mod n] = 1 then break fi;
%p A004290    L[m,0]:= 1;
%p A004290    for k from 1 to n-1 do
%p A004290      L[m,k]:= max(L[m-1,k],L[m-1,k-10^m mod n])
%p A004290    od;
%p A004290 od;
%p A004290 r:= 10^m; k:= -10^m mod n;
%p A004290 for j from m-1 by -1 to 1 do
%p A004290     if L[j-1,k] = 0 then
%p A004290       r:= r + 10^j; k:= k - 10^j mod n;
%p A004290     fi
%p A004290 od;
%p A004290 if k = 1 then r:= r + 1 fi;
%p A004290 r
%p A004290 end proc:
%p A004290 seq(f(n),n=1..100); # _Robert Israel_, Feb 09 2016
%t A004290 a[n_] := For[k = 1, True, k++, b = FromDigits[ IntegerDigits[k, 2] ]; If[Mod[b, n] == 0, Return[b]]]; a[0] = 0; Table[a[n], {n, 0, 34}] (* _Jean-François Alcover_, Jun 14 2013, after _Reinhard Zumkeller_ *)
%t A004290 With[{c=Rest[Union[FromDigits/@Flatten[Table[Tuples[{1,0},i],{i,10}], 1]]]}, Join[{0},Flatten[ Table[ Select[c,Divisible[#,n]&,1],{n,40}]]]] (* _Harvey P. Dale_, Dec 07 2013 *)
%o A004290 (Haskell)
%o A004290 a004290 0 = 0
%o A004290 a004290 n = head [x | x <- tail a007088_list, mod x n == 0]
%o A004290 -- _Reinhard Zumkeller_, Jan 10 2012
%o A004290 (Python) def A004290(n):
%o A004290     if n > 0:
%o A004290         for i in range(1,2**n):
%o A004290             x = int(bin(i)[2:])
%o A004290             if not x % n:
%o A004290                 return x
%o A004290     return 0
%o A004290 # _Chai Wah Wu_, Dec 30 2014
%o A004290 (PARI) a(n) = {if( n==0, return (0)); my(m = n); while (vecmax(digits(m)) != 1, m+=n); m;} \\ _Michel Marcus_, Feb 09 2016, May 27 2020
%o A004290 (PARI) apply( {A004290(n)=for(k=1,2^n,(t=fromdigits(binary(k)))%n||return(t))}, [1..44]) \\ _M. F. Hasler_, Mar 04 2025
%Y A004290 Cf. A004283-A004289, A078241-A078248, A079339, A096681-A096688, A257345.
%K A004290 nonn,base,nice
%O A004290 1,2
%A A004290 _David W. Wilson_
%E A004290 Initial 0 deleted and offset corrected by _N. J. A. Sloane_, Jan 31 2024