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 #51: Prime digit replacements

Project Euler #51: Prime digit replacements

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 51 from projecteuler.net. We highly recommend to solve original first

By replacing the digit of , it turns out that six of the nine possible values: , , , , , and , are all prime.

By replacing the and digits of with the same digit, this number is the first example having seven primes among the ten generated numbers, yielding the family: , , , , , , and . Consequently , being the first member of this family, is the smallest prime with this property.

Find the smallest prime which, by replacing of the number (not necessarily adjacent digits) with the same digit, is part of an prime value family.

Note1: It is guaranteed that solution does exist.
Note2: Leading zeros should not be considered.
Note3: If there are several solutions, choose the "lexicographically" smallest one (one sequence is considered "lexicographically" smaller than another if its first element which does not match the corresponding element in another sequence is smaller)

Input Format
Input contains three integers , and .

Output Format
Print the first L numbers of the prime value family found in increasing order.

Constraints


Sample Input#00

5 2 7

Sample Output#00

56003 56113 56333 56443 56663 56773 56993

Sample Input#01

2 1 3

Sample Output#01

11 13 17

Author

shashank21j

Difficulty

Advanced

Max Score

100

Submitted By

1266

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