%I #17 Jul 08 2014 00:19:38
%S 1,8,28,328,1328,11328
%N Least number k > 0 such that 2^k ends in exactly n consecutive increasing digits.
%C For n = {1, 2, 3, 4, 5, 6}, the n consecutive increasing digits, given by 2^a(n)%10^n, are {2, 56, 456, 3456, 23456, 123456}, respectively.
%C There are 12500 possible 6-digit endings for 2^k. There are no k-values such that 2^k ends in '234567', '345678', or '456789'. The k-values for which 2^k ends in '123456' are given by 11328 mod 12500. For k = 11328 + 12500*x, the digit immediately before the run of '123456' is {1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, ...} for x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...}, respectively. Thus, we see the digit before will never be 0. So, this sequence is full.
%e 2^8 = 256 ends in '56'. Thus a(2) = 8.
%e 2^28 ends in '456'. Thus a(3) = 28.
%o (PARI) a(n)=for(k=1,10^6,st=2^k;c=0;if(#Str(st)>n,for(i=1,n,if(((st-(st%10^(i-1)))/10^(i-1))%10==((st-(st%10^i))/10^i)%10+1,c++));if(c==n,return(k))))
%o n=0;while(n<10,print1(a(n),", ");n++)
%o (Python)
%o def a(n):
%o ..for k in range(1,10**5):
%o ....st = str(2**k)
%o ....if len(st) > n:
%o ......count = 0
%o ......for i in range(len(st)):
%o ........if int(st[len(st)-1-i]) == int(st[len(st)-2-i])+1:
%o ..........count += 1
%o ........else:
%o ..........break
%o ......if count == n:
%o ........return k
%o n = 0
%o while n < 10:
%o ..print(a(n),end=', ')
%o ..n += 1
%K nonn,base,fini,full
%O 1,2
%A _Derek Orr_, Jul 02 2014
|