Right-Truncatable Prime Counter
Published on: 2025-06-16 09:54:40
Right-Truncatable Prime Counter
This C program efficiently calculates the number of right-truncatable primes for a given number of digits. It uses a custom hash table for fast primality lookups and the primesieve library for high-performance prime generation.
A right-truncatable prime is a prime number that, when its rightmost digit is successively removed, results in a sequence of primes. For example, 739 is a right-truncatable prime because:
739 is prime.
Removing the rightmost '9' gives 73, which is prime.
Removing the rightmost '3' from 73 gives 7, which is prime.
There are 83 right-truncatable primes. The complete list:
2, 3, 5, 7, 23, 29, 31, 37, 53, 59, 71, 73, 79, 233, 239, 293, 311, 313, 317, 373, 379, 593, 599, 719, 733, 739, 797, 2333, 2339, 2393, 2399, 2939, 3119, 3137, 3733, 3739, 3793, 3797, 5939, 7193, 7331, 7333, 7393, 23333, 23339, 23399, 23993, 29399, 31193, 31379, 37337, 37339, 37397, 59393, 59399, 71933, 73331, 73939, 233993, 239933, 293999, 373379, 373393, 5
... Read full article.