A068669 Noncomposite numbers in which every substring is noncomposite.
1, 2, 3, 5, 7, 11, 13, 17, 23, 31, 37, 53, 71, 73, 113, 131, 137, 173, 311, 313, 317, 373, 1373, 3137
Offset: 1
Examples
137 is a member as all the substrings, i.e. 1, 3, 7, 13, 37, 137, are noncomposite. All substrings of 3137 are noncomposite numbers: 1, 3, 7, 13, 37, 137, 313, 3137. - _Jaroslav Krizek_, Dec 25 2011
Programs
-
Mathematica
noncompositeQ[n_] := n == 1 || PrimeQ[n]; Reap[ Do[ id = IntegerDigits[n]; lid = Length[id]; test = And @@ noncompositeQ /@ FromDigits[#, 10]& /@ Flatten[ Table[ Take[id, {i, j}], {i, 1, lid}, {j, i, lid}], 1]; If[test, Sow[n]], {n, Join[{1}, Prime /@ Range[10000]]}]][[2, 1]](* Jean-François Alcover, May 09 2012 *)
Extensions
1 added following a redefinition by Jaroslav Krizek. - R. J. Mathar, Jan 20 2012
Comments