Question: Python Code By replacing the 1 st digit of * 3 , it turns out that six of the nine possible values: 1 3 ,

Python Code
By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13,23,43,53,73, and 83, are all prime.
By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 56003,56113,56333,56443,56663,56773, and 56993. Consequently 56003, being the first member of this family, is the smallest prime with this property.
Find the smallest N-digit prime which, by replacing K-digits of the number (not necessarily adjacent digits) with the same digit, is part of an L 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 N, K and L.
Output Format
Print the first L numbers of the prime value family found in increasing order.
Constraints
2<=N<=7
1<=K<=N
1<=L<=8
Sample Input#00
527
Sample Output#00
56003561135633356443566635677356993
Sample Input#01
213
Sample Output#01
111317

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!