Digitally delicate primes
A digitally delicate prime is a prime number such that if any of its digits are changed by any amount, the result is not prime. The smallest such number is 294001. This means that variations on this number such as 394001 or 291001 or 294081 are all composite.
A paper [1] posted last week gives several new results concerning digitally delicate primes. Here I'll just mention a few things that are known.
First, there are infinitely many digitally delicate primes. They are uncommon, but they have positive density. That is, as x goes to infinity, the ratio of the number of digitally delicate primes less than x to the total number of primes less than x converges to a small positive number.
This result has been extended to bases other than base 10. In [1] the authors extend the result to widely digitally delicate primes, meaning that the result holds even if you consider the digits" of a number to include leading zeros.
The following Python code tests whether a number is a digitally delicate prime. It then takes the first six digitally delicate primes and verifies that they are indeed digitally delicate.
from sympy import isprimefrom math import floor, log10def num_digits(n): return floor(log10(n))+1def digit_in_pos(n, pos): return (n // 10**pos) % 10def set_digit(n, pos, new): "change digit in given position to new value" old = digit_in_pos(n, pos) return n + (new - old)*10**posdef is_digitally_delicate_prime(n): if not isprime(n): return False nd = num_digits(n) for pos in range(nd): for newdigit in range(1, 10): if digit_in_pos(n, pos) == newdigit: continue m = set_digit(n, pos, newdigit) if isprime(m): print("m = ", m) return False return Truefor p in [294001, 505447, 584141, 604171, 971767, 1062599]: print(is_digitally_delicate_prime(p))
[1] Michael Filaseta and Jeremiah Southwick. Primes that become composite after changing an arbitrary digit. Mathematics of Computation. Article electronically published on November 24, 2020. https://doi.org/10.1090/mcom/3593
The post Digitally delicate primes first appeared on John D. Cook.