login
a(n) is the least k such that the rightmost 7 in the decimal expansion of 3^k is in the (10^n)'s position, or -1 if there is no such k.
0

%I #10 May 25 2023 07:51:44

%S 3,-1,6,37,50,14,18,38,28,25,48,188,34,93,45,40,44,134,54,60,96,86,61,

%T 81,229,57,133,321,89,412,628,210,200,257,429,256,313,672,885,530,

%U 2418,649,270,641,848,258,2676,121,450,1448,3254,696,9857,4961,804,6101,1049,1476,5044,3186,437,12560

%N a(n) is the least k such that the rightmost 7 in the decimal expansion of 3^k is in the (10^n)'s position, or -1 if there is no such k.

%C Conjecture: a(n) = -1 only for n = 1.

%e a(4) = 50 because 3^50 = 717897987691852588770249 has its rightmost 7 in the (10^4)'s position, and no k < 50 works.

%p W:= Array(0..70): count:= 0: W[1]:= -1:

%p for k from 1 while count < 70 do

%p L:= convert(3^k,base,10);

%p for j from 1 to min(nops(L),101) do

%p if L[j] = 7 then

%p if W[j-1] = 0 then W[j-1]:= k; count:= count+1; fi;

%p break

%p fi

%p od

%p od:

%p convert(W[0..70],list);

%o (Python)

%o from itertools import count

%o def aupto(N):

%o M, adict, n, k = 10**(N+1), {-1:None, 0:3, 1:-1}, 0, 0

%o while n < N:

%o while n in adict: yield adict[n]; n += 1

%o v = str(pow(3, k, M))[::-1].find("7")

%o if v not in adict:

%o adict[v] = k

%o k += 1

%o print(list(aupto(62))) # _Michael S. Branicky_, May 21 2023

%Y Cf. A000244.

%K sign,base

%O 0,1

%A _Robert Israel_, May 20 2023