|
| |
|
|
A068877
|
|
Largest n-digit prime with property that digits alternate in parity.
|
|
2
| |
|
|
7, 89, 983, 8969, 98981, 898987, 9898921, 89898983, 989898989, 8989898969, 98989898981, 898989898987, 9898989898901, 89898989898967, 989898989898943, 8989898989898969, 98989898989898981, 898989898989898943, 9898989898989898789
(list; graph; refs; listen; history; internal format)
|
|
|
|
OFFSET
| 1,1
|
|
|
EXAMPLE
| a(4) = 8969 as 8, 9, 6 and 9 have even and odd parity alternately.
|
|
|
PROG
| (Sage)
concat = lambda x: Integer(''.join(map(str, x)), base=10)
def A068877(n):
....dd = {0:range(0, 10, 2)[::-1], 1: range(1, 10, 2)[::-1]}
....for d0 in [1..9][::-1]:
........if n % 2 == 0 and d0 % 2 == 1: continue # optimization
........ds = [dd[(d0+1+i) % 2] for i in range(n-1)]
........for dr in CartesianProduct(*ds):
............c = concat([d0]+dr)
............if is_prime(c): return c # [D. S. McNeil, Apr 2 2011]
|
|
|
CROSSREFS
| Cf. A030144, A068876.
Sequence in context: A068692 A178006 A053302 * A121044 A107109 A089771
Adjacent sequences: A068874 A068875 A068876 * A068878 A068879 A068880
|
|
|
KEYWORD
| nonn,base
|
|
|
AUTHOR
| Amarnath Murthy (amarnath_murthy(AT)yahoo.com), Mar 19 2002
|
|
|
EXTENSIONS
| a(15)-a(19) from Donovan Johnson (donovan.johnson(AT)yahoo.com), Apr 01 2011
|
| |
|
|