We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #37: Truncatable primes

Project Euler #37: Truncatable primes

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 37 from projecteuler.net

The number has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: , , , and . Similarly we can work from right to left: , , , and .

Find the sum of primes that are both truncatable from left to right and right to left below .

NOTE: , , , and are not considered to be truncatable primes.

Input Format

Input contains an integer .

Constraints

Output Format

Print the answer corresponding to the test case.

Sample Input

100

Sample Output

186

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

3605

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy