Deletable Prime

Author

Eric W. Weisstein
January 7, 2007

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegerSequences/DeletablePrime.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/DeletablePrime.html.

©2007 Wolfram Research, Inc. except for portions noted otherwise

Code

Deletes[l_]:=Delete[l,#]&/@Range[Length[l]]
DeletedPrimes[l_]:=Union[Flatten[Function[f,Select[Deletes[f],PrimeQ[FromDigits[#]]&]]/@l,1]]
DeletablePrimeList[n_]:=Module[{d={IntegerDigits[n]}},NestList[DeletedPrimes,d,Length[d[[1]]]-1]
]
DeletablePrimeQ[n_]:=Module[{d={IntegerDigits[n]}},PrimeQ[n]&&Nest[DeletedPrimes,d,Length[d[[1]]]-1]=!={}
]

Example

DeletablePrimeList[4102566793]//ColumnForm

DeletablePrimeQ[4102566793]

Select[Range[200],DeletablePrimeQ]