login
Prime numbers that yield a squarefree semiprime when any digit is removed.
1

%I #14 May 26 2024 16:13:34

%S 557,577,587,857,877,1559,4111,4973,5051,5119,5519,5591,6299,6679,

%T 6871,6899,6949,7213,7789,7949,7993,8669,8699,9133,9221,9551,9749,

%U 10111,10799,11119,11149,11159,11411,11959,12073,12119,13337,13397,13829,14411,15137,15461

%N Prime numbers that yield a squarefree semiprime when any digit is removed.

%C The smallest prime with this property is 557. Since being primes, the terms of this sequence end in 1, 3, 7 or 9 and the penultimate digit is never 0, otherwise by eliminating the last digit the resulting number is not semiprime.

%e 857 is a term, because it is a prime number such that if the 8 is removed, the result is 57 = 3 * 19, while if the 5 is removed, the result is 87 = 3 * 29 and if the 7 is removed, the result is 85 = 5 * 17.

%t semiPrimeQ[n_] := FactorInteger[n][[;;,2]] == {1, 1}; q[n_] := AllTrue[FromDigits@ Drop[IntegerDigits[n], {#}] & /@ Range[IntegerLength[n]], semiPrimeQ]; Select[Prime[Range[2000]], q] (* _Amiram Eldar_, May 26 2024 *)

%o (Python)

%o from sympy import factorint, isprime

%o def ok(n):

%o if n < 10 or not isprime(n): return False

%o s = str(n)

%o for i in range(len(s)):

%o ti = int(s[:i] + s[i+1:])

%o f = factorint(ti)

%o if not len(f) == 2 == sum(f.values()):

%o return False

%o return True

%o print([k for k in range(16000) if ok(k)]) # _Michael S. Branicky_, May 25 2024

%Y Cf. A000040, A006881.

%K base,nonn

%O 1,1

%A _Gonzalo Martínez_, May 25 2024