cyberangles blog

Exploring Right-Truncatable Primes: A Deep Dive

In the fascinating world of prime numbers, there are many special subsets that have intrigued mathematicians for years. One such subset is the right-truncatable primes. These are prime numbers that remain prime even when we successively truncate (remove) the rightmost digit. For example, consider the number 7393. If we truncate the rightmost digit, we get 739 (which is prime). Truncating again gives 73 (prime), and one more truncation gives 7 (prime). In this blog, we'll explore what right-truncatable primes are, how to identify them, and some interesting properties and examples.

2026-07

Table of Content#

  1. Definition of Right-Truncatable Primes
  2. How to Check for Right-Truncatable Primes
    • Prime Checking Algorithm
    • Truncation Process
  3. Example Usage
    • Finding Small Right-Truncatable Primes
    • Larger Examples and Patterns
  4. Properties and Significance
  5. Best Practices in Studying Right-Truncatable Primes
  6. Common Pitfalls to Avoid
  7. References

1. Definition of Right-Truncatable Primes#

A right-truncatable prime (p) is a prime number such that for every (k) from (1) to (n - 1) (where (n) is the number of digits of (p)), the number formed by removing the last (k) digits of (p) is also a prime. Mathematically, if (p=a_m10^m + a_{m - 1}10^{m - 1}+\cdots+a_110 + a_0) (where (a_i) are digits), then (a_m10^{m - 1}+a_{m - 1}10^{m - 2}+\cdots+a_1), (a_m10^{m - 2}+a_{m - 1}10^{m - 3}+\cdots+a_2), etc., must all be prime.

2. How to Check for Right-Truncatable Primes#

Prime Checking Algorithm#

To check if a number (n) is prime, we can use the following simple algorithm (for small to moderate numbers). For (n>1), we check if (n) is divisible by any integer (i) from (2) to (\sqrt{n}). If it is not divisible by any of these (i)s, then (n) is prime.

Truncation Process#

Let's say we have a number (N). To truncate it from the right, we can use the integer division operation. For example, if (N = 1234), then (N\div10 = 123) (truncated by one digit), (N\div100=12) (truncated by two digits), and so on.

3. Example Usage#

Finding Small Right-Truncatable Primes#

Let's start with single-digit primes: (2), (3), (5), (7). These are trivially right-truncatable primes (since there's nothing to truncate after them).

For two-digit numbers:

  • Consider (11). Truncating gives (1) (not prime). So, it's not a right-truncatable prime.
  • Consider (13). Truncating gives (1) (not prime).
  • Consider (23). Truncating gives (2) (prime). So, (23) is a right-truncatable prime.

Larger Examples and Patterns#

Take (739393).

  • Truncate one digit: (73939) (check if prime. Let's assume it is for now).
  • Truncate two digits: (7393) (prime, as we saw in the introduction).
  • Truncate three digits: (739) (prime).
  • Truncate four digits: (73) (prime).
  • Truncate five digits: (7) (prime).

Another example is (3137).

  • Truncate one digit: (313) (prime).
  • Truncate two digits: (31) (prime).
  • Truncate three digits: (3) (prime).

4. Properties and Significance#

  • Rarity: Right-truncatable primes are relatively rare. As the number of digits increases, the probability of a number being a right-truncatable prime decreases because more conditions (all truncations being prime) need to be satisfied.
  • Connection to Number Theory: Studying them helps in understanding the distribution of primes and how prime properties can be maintained under simple digit - removal operations.

5. Best Practices in Studying Right-Truncatable Primes#

  • Efficient Prime Checking: Use more advanced prime - checking algorithms like the Sieve of Eratosthenes (for a range of numbers) or probabilistic primality tests (like the Miller - Rabin test) for larger numbers.
  • Iterative Truncation: Implement a loop in a programming language (e.g., Python) to perform the truncation and prime - checking steps automatically. For example, in Python:
def is_prime(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True
 
 
def is_right_truncatable_prime(n):
    while n > 0:
        if not is_prime(n):
            return False
        n = n // 10
    return True

6. Common Pitfalls to Avoid#

  • Forgetting Single - Digit Primes: Remember that single - digit primes ((2), (3), (5), (7)) are valid right-truncatable primes.
  • Incorrect Truncation: Make sure that the truncation operation (e.g., integer division) is implemented correctly. For example, in some programming languages, division of integers might return a float if not done properly.

7. References#

  • "Prime Numbers: A Computational Perspective" by Richard Crandall and Carl Pomerance. This book covers various aspects of prime number theory, including primality testing algorithms.
  • Online resources like the OEIS (Online Encyclopedia of Integer Sequences) which has sequences related to right-truncatable primes (e.g., sequence A024770 for right-truncatable primes).

By understanding right-truncatable primes, we gain a deeper appreciation for the unique properties of prime numbers and how simple operations can reveal interesting mathematical patterns. Whether you're a mathematician, a computer scientist, or just a math enthusiast, these numbers offer a rich area for exploration.