login
A244655
Least number k such that 3^k ends in exactly n consecutive decreasing digits.
0
1, 5, 27, 496, 4996, 49996, 499996, 4999996, 49999996
OFFSET
1,2
COMMENTS
The n consecutive decreasing digits, given by 3^a(n)%10^n, are {3, 43, 987, 4321, 54321, 654321, 7654321, 87654321, 987654321}, respectively.
EXAMPLE
3^27 ends in '987' (3 digits) and is the smallest power of 3 to end in '987', '876', '765', '654', '543', '432', '321', or '210'. So a(3) = 27.
PROG
(PARI) a(n)=for(k=1, 10^9, st=3^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))))
n=0; while(n<10, print1(a(n), ", "); n++)
(Python)
def a(n):
..for k in range(1, 10**9):
....st = str(3**k)
....if len(st) > n:
......count = 0
......for i in range(len(st)):
........if int(st[len(st)-1-i]) == int(st[len(st)-2-i])-1:
..........count += 1
........else:
..........break
......if count == n:
........return k
n = 0
while n < 10:
..print(a(n), end=', ')
..n += 1
CROSSREFS
Cf. A244613.
Sequence in context: A265907 A360732 A135627 * A002401 A034946 A321072
KEYWORD
nonn,base,fini,full
AUTHOR
Derek Orr, Jul 03 2014
STATUS
approved