A254751 Numbers such that, in base 10, all their proper prefixes and suffixes represent primes.
22, 23, 25, 27, 32, 33, 35, 37, 52, 53, 55, 57, 72, 73, 75, 77, 237, 297, 313, 317, 373, 537, 597, 713, 717, 737, 797, 2337, 2397, 2937, 3113, 3137, 3173, 3797, 5937, 5997, 7197, 7337, 7397, 29397, 31373, 37937, 59397, 73313, 739397
Offset: 1
Examples
6 is not a member because its expansion cannot be sliced in two. 597 is a member because (5,97,59, and 7) are all primes. 2331 is excluded because 233 is prime, but 1 is not. - _Gordon Hamilton_, Feb 20 2015
Programs
-
Mathematica
fQ[n_] := (p = {2, 3, 5, 7}; If[ Union@ Join[p, {Mod[n, 10]}] != p, {False}, Block[{idn = IntegerDigits@ n, lng = Floor@ Log10@ n}, Union@ PrimeQ@ Flatten@ Table[{FromDigits[ Take[idn, i]], FromDigits[ Take[idn, -lng + i - 1]]}, {i, lng}] == {True}]]); Select[ Range@1000000, fQ] (* Robert G. Wilson v, Feb 21 2015 *) Select[Range[10,750000],AllTrue[Flatten[Table[FromDigits/@TakeDrop[IntegerDigits[#],n],{n,IntegerLength[#]-1}]],PrimeQ]&] (* Harvey P. Dale, Feb 13 2024 *)
-
PARI
slicesIntoPrimes(n,b=10) = {my(k=b);if(n0,if(!isprime(n\k)||!isprime(n%k),return(0););k*=b;);return(1);}
-
Sage
def breakIntoPrimes(n): D=n.digits() for i in [1..len(D)-1]: if not(is_prime(sum(D[i:][j]*10^j for j in range(len(D[i:])))) and is_prime(sum(D[:i][j]*10^j for j in range(len(D[:i]))))): return False else: continue return True [n for n in [10..1000] if breakIntoPrimes(n)] # Tom Edgar, Feb 20 2015
Comments