[go: up one dir, main page]

login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A244655 Least number k such that 3^k ends in exactly n consecutive decreasing digits. 0

%I #7 Jul 08 2014 00:19:50

%S 1,5,27,496,4996,49996,499996,4999996,49999996

%N Least number k such that 3^k ends in exactly n consecutive decreasing digits.

%C The n consecutive decreasing digits, given by 3^a(n)%10^n, are {3, 43, 987, 4321, 54321, 654321, 7654321, 87654321, 987654321}, respectively.

%e 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.

%o (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))))

%o n=0; while(n<10, print1(a(n), ", "); n++)

%o (Python)

%o def a(n):

%o ..for k in range(1, 10**9):

%o ....st = str(3**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

%Y Cf. A244613.

%K nonn,base,fini,full

%O 1,2

%A _Derek Orr_, Jul 03 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 30 19:33 EDT 2024. Contains 375545 sequences. (Running on oeis4.)