|
|
A244655
|
|
Least number k such that 3^k ends in exactly n consecutive decreasing digits.
|
|
0
|
|
|
|
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.
|
|
LINKS
|
|
|
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
|
|
|
KEYWORD
|
nonn,base,fini,full
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|