login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A096681
Least k such that decimal representation of k*n contains only digits 0 and 2.
18
2, 1, 74, 5, 4, 37, 286, 25, 24691358, 2, 2, 185, 154, 143, 148, 125, 1306, 12345679, 1158, 1, 962, 1, 9574, 925, 8, 77, 81563786, 715, 75938, 74, 7162, 625, 6734, 653, 572, 61728395, 6, 579, 518, 5, 542, 481, 51214, 5, 49382716, 4787, 426, 4625, 44898, 4
OFFSET
1,1
LINKS
FORMULA
a(n) = A078241(n)/n.
PROG
(PARI) isok(n) = my(vd = vecsort(digits(n), , 8)); (vd == [0, 2]) || (vd == [2]);
a(n) = my(k=1); while(!isok(k*n), k++); k; \\ Michel Marcus, Sep 25 2016
(Python)
def next02(n):
s = str(n)
if s > '2'*len(s): return int('2' + '0'*len(s))
for i, c in enumerate(s):
if c == '1': return int(s[:i] + '2' + '0'*(len(s)-i-1))
elif s[i:] > '2'*(len(s)-i): return int(s[:i-1] + '2' + '0'*(len(s)-i))
def a(n):
k = 1
while set(str(k*n)) - set('02') != set(): k = max(k+1, next02(k*n)//n)
return k
print([a(n) for n in range(1, 51)]) # Michael S. Branicky, Feb 01 2021
KEYWORD
base,nonn
AUTHOR
Ray Chandler, Jul 12 2004
STATUS
approved