OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..700
EXAMPLE
a(4) = 2129 as 2, 1, 2 and 9 have even and odd parity alternately.
MAPLE
alp:= proc(n) local L, d;
L:= convert(n, base, 10);
d:= nops(L);
if d::even then L:= L + map(op, [[0, 1]$(d/2)]) else L:= L + map(op, [[0, 1]$((d-1)/2), [0]]) fi;
nops(convert(L mod 2, set))=1
end proc:
f:= proc(d) local s;
if d::even then s:= 2*10^(d-1)+(10^d-1)/99-1
else s:= (10^(d+1)-1)/99-1
fi;
do s:= nextprime(s);
if alp(s) then return s fi
od
end proc:
seq(f(d), d=1..20); # Robert Israel, Aug 14 2018
MATHEMATICA
fQ[n_] := Block[{m = Mod[ IntegerDigits@ n, 2]}, m == Split[m, UnsameQ][[1]]]; f[n_] := Block[{c = 1 + 100 (100^Ceiling[n/2 - 1] - 1)/99, k}, k = If[ OddQ@ n, c, 2*10^(n - 1) + c]; k = NextPrime[k - 1]; While[ !fQ@ k, k = NextPrime@ k]; k]; Array[f, 21] (* Robert G. Wilson v, Apr 01 2011 *)
PROG
(Sage)
concat = lambda x: Integer(''.join(map(str, x)), base=10)
def A068876(n):
dd = {0:range(0, 10, 2), 1: range(1, 10, 2)}
for d0 in [1..9]:
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 cartesian_product(ds):
c = concat([d0]+dr)
if is_prime(c): return c # D. S. McNeil, Apr 02 2011
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Amarnath Murthy, Mar 19 2002
EXTENSIONS
a(9)-a(13) corrected and a(14)-a(19) from Donovan Johnson, Apr 01 2011
STATUS
approved