Efficient Right-Truncatable Prime Counter in C

2025-05-27
Efficient Right-Truncatable Prime Counter in C

This C program efficiently calculates the number of right-truncatable primes for a given number of digits. It utilizes a custom hash table for fast primality checks and the primesieve library for optimized prime generation. A right-truncatable prime remains prime after successively removing its rightmost digit. The program handles input from 1 to 19 digits, reporting the count of right-truncatable primes for each digit length and the total execution time. For example, for 8-digit numbers, it finds 5 such primes and a total of 83 up to 8 digits.

Development