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!)
A068877 Largest n-digit prime with property that digits alternate in parity. 2

%I #16 Mar 08 2020 00:04:22

%S 7,89,983,8969,98981,898987,9898921,89898983,989898989,8989898969,

%T 98989898981,898989898987,9898989898901,89898989898967,

%U 989898989898943,8989898989898969,98989898989898981,898989898989898943,9898989898989898789

%N Largest n-digit prime with property that digits alternate in parity.

%H Giovanni Resta, <a href="/A068877/b068877.txt">Table of n, a(n) for n = 1..500</a>

%e a(4) = 8969 as 8, 9, 6 and 9 have even and odd parity alternately.

%o (Sage)

%o concat = lambda x: Integer(''.join(map(str,x)),base=10)

%o def A068877(n):

%o dd = {0:range(0,10,2)[::-1], 1: range(1,10,2)[::-1]}

%o for d0 in [1..9][::-1]:

%o if n % 2 == 0 and d0 % 2 == 1: continue # optimization

%o ds = [dd[(d0+1+i) % 2] for i in range(n-1)]

%o for dr in cartesian_product(ds):

%o c = concat([d0]+dr)

%o if is_prime(c): return c # [_D. S. McNeil_, Apr 02 2011]

%Y Cf. A030144, A068876.

%K nonn,base

%O 1,1

%A _Amarnath Murthy_, Mar 19 2002

%E a(15)-a(19) from _Donovan Johnson_, Apr 01 2011

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 April 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)