login
Smallest number m such that 3^m contains a string of n consecutive decreasing integers in its decimal representation.
0

%I #9 Mar 08 2014 10:59:18

%S 0,5,13,50,213,536,536,4582,63202,163984

%N Smallest number m such that 3^m contains a string of n consecutive decreasing integers in its decimal representation.

%e 5 is the smallest exponent such that 3^5 contains two consecutive decreasing integers (3^5 = 243).

%e 13 is the smallest exponent such that 3^13 contains three consecutive decreasing integers (3^13 = 1594323).

%o (Python)

%o def StrDec(x):

%o ..for n in range(10**5):

%o ....count = 0

%o ....i = 0

%o ....string = str(3**n)

%o ....if len(string) == x and x == 1:

%o ......return n

%o ....while i < len(string)-1:

%o ......if int(string[i]) == int(string[i+1])-1:

%o ........count += 1

%o ........i += 1

%o ......else:

%o ........if count >= x-1:

%o ..........return n

%o ........else:

%o ..........count = 0

%o ..........i += 1

%o ....if count >= x-1:

%o ......return n

%o x = 1

%o while x < 15:

%o ..print(StrDec(x))

%o ..x += 1

%Y Cf. A238449, A215727.

%K nonn,base,fini,full

%O 1,2

%A _Derek Orr_, Feb 27 2014

%E a(9)-a(10) from _Giovanni Resta_, Mar 02 2014