Solution to Project Euler Problem 37: Truncatable primes - The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3. Find the sum of the only eleven primes that are both truncatable from left to right and right to left. NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.


Updated: June 1, 2023 — Training Time: 3 minutes
Overseen by: Archangel Macsika
All Training Resources

Scroll for more menu list

Topic: Project Euler Problem 37: Truncatable primes.

Difficulty: Easy.

Objective: The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
Find the sum of the only eleven primes that are both truncatable from left to right and right to left.
NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.

Input: None.

Expected Output: 748317.

Sikademy Solution in Java Programming Language

Sikademy Solution in Python Programming Language

Was this training resource helpful?