CT104

Truncatable Primes

MediumAcceptance: 0.0%

The number 3797 is a truncatable prime: left-to-right truncation yields 3797, 797, 97, 7 (all prime), and right-to-left yields 3797, 379, 37, 3 (all prime). Given count N, find the sum of the first N truncatable primes (from both left to right and right to left). Single-digit primes are not considered truncatable.

Example 1:

Input: 11
Output: 748317

Example 2:

Input: 3
Output: 113

Example 3:

Input: 5
Output: 499

Constraints:

1 <= N <= 11

Tags:

math prime-numbers truncatable
Loading...
Test Cases:No test cases
No test cases available.