login
Primes such that all digits (except perhaps the least significant digit) are even.
13

%I #29 Sep 24 2019 09:38:39

%S 2,3,5,7,23,29,41,43,47,61,67,83,89,223,227,229,241,263,269,281,283,

%T 401,409,421,443,449,461,463,467,487,601,607,641,643,647,661,683,809,

%U 821,823,827,829,863,881,883,887,2003,2027,2029,2063,2069,2081,2083,2087

%N Primes such that all digits (except perhaps the least significant digit) are even.

%C Essentially the same as A154764.

%H Zak Seidov, <a href="/A068690/b068690.txt">Table of n, a(n) for n = 1..10775</a> (all terms < 10^8.)

%e 2 is in the sequence even though the least significant digit of 2 is even instead of odd. - _David A. Corneth_, Sep 18 2019

%t (*returns true if all but the last digit of n is even, false o.w.*) f[n_] := Module[{a, l, i, r = True}, a = IntegerDigits[n]; l = Length[a]; For[i = 1, i < l, i++, If[Mod[a[[i]], 2] == 1, r = False; Break[ ]]]; r]; Select[Range[1, 4*10^3], PrimeQ[ # ] && f[ # ] &]

%t m = 7; Prepend[Reap[Do[If[PrimeQ[fd = FromDigits[{a[1], a[2], a[3], a[4], a[5], a[6], a[m]}]], Sow[fd]], {a[1], 0, 8, 2}, {a[2], 0, 8, 2}, {a[3], 0, 8, 2}, {a[4], 0, 8, 2}, {a[5], 0, 8, 2}, {a[6], 0, 8, 2}, {a[m], 1, 9, 2}]][[2, 1]], 2] (* all terms < 10^8. _Zak Seidov_, Jan 29 2013 *)

%t Select[ Prime@ Range[10000], ContainsAll[{0, 2, 4, 6, 8}, Most@ IntegerDigits[#]] &] (* From version 10. _Mikk Heidemaa_, Feb 08 2016 *)

%t Select[Prime[Range[400]],AllTrue[Most[IntegerDigits[#]],EvenQ]&] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Sep 18 2019 *)

%o (Haskell)

%o a068690 n = a068690_list !! (n-1)

%o a068690_list = filter (all (`elem` "02468") . init . show) a000040_list

%o -- _Reinhard Zumkeller_, Apr 28 2014

%Y Cf. A030096, A154764.

%K base,easy,nonn

%O 1,1

%A _Amarnath Murthy_ and _Joseph L. Pe_, Mar 03 2002

%E Definition rephrased by _N. J. A. Sloane_, Dec 11 2007