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 #60: Prime pair sets

Project Euler #60: Prime pair sets

Problem
Submissions
Leaderboard
Discussions

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

The primes , , , and , are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four primes with this property.

Find the sum of all set of for which any two primes concatenate to produce another prime. Print the sum in sorted order.

Input Format

Input contains two integers separated by a space .

Constraints


Output Format

Print the sum of , one in each line.

Sample Input

100 3

Sample Output

107
123

Explanation

TL for this challenge has been adjusted as slow language like Python, PHP scaled by 1.8 times, Medium languages like Haskell are scaled 1.4 times and fast languages remains as it is.
This challenge is tested to work in C++ and Python. If there are no submission in your preferred language feel free to write in discussions page.

Author

shashank21j

Difficulty

Hard

Max Score

100

Submitted By

1184

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