login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A096681 Least k such that decimal representation of k*n contains only digits 0 and 2. 18

%I #18 Feb 01 2021 16:46:11

%S 2,1,74,5,4,37,286,25,24691358,2,2,185,154,143,148,125,1306,12345679,

%T 1158,1,962,1,9574,925,8,77,81563786,715,75938,74,7162,625,6734,653,

%U 572,61728395,6,579,518,5,542,481,51214,5,49382716,4787,426,4625,44898,4

%N Least k such that decimal representation of k*n contains only digits 0 and 2.

%H Robert G. Wilson v, <a href="/A096681/b096681.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A078241(n)/n.

%o (PARI) isok(n) = my(vd = vecsort(digits(n),,8)); (vd == [0,2]) || (vd == [2]);

%o a(n) = my(k=1); while(!isok(k*n), k++); k; \\ _Michel Marcus_, Sep 25 2016

%o (Python)

%o def next02(n):

%o s = str(n)

%o if s > '2'*len(s): return int('2' + '0'*len(s))

%o for i, c in enumerate(s):

%o if c == '1': return int(s[:i] + '2' + '0'*(len(s)-i-1))

%o elif s[i:] > '2'*(len(s)-i): return int(s[:i-1] + '2' + '0'*(len(s)-i))

%o def a(n):

%o k = 1

%o while set(str(k*n)) - set('02') != set(): k = max(k+1, next02(k*n)//n)

%o return k

%o print([a(n) for n in range(1, 51)]) # _Michael S. Branicky_, Feb 01 2021

%Y Cf. A004290, A078241-A078248, A079339, A096682, A096683, A096684, A096685, A096686, A096687, A096688.

%K base,nonn

%O 1,1

%A _Ray Chandler_, Jul 12 2004

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 05:56 EDT 2024. Contains 371964 sequences. (Running on oeis4.)