Given a number N, the task is to find two composite numbers X and Y, such that difference between them is equal to N. Note that there can be multiple answers for this task. Print any one of them.
Input: N = 4 Output: X = 36, Y = 32 Input: N = 1 Output: X = 9, Y = 8
- We have to find X – Y = N.
- We know, minimum value of N can be 0 or 1. If it is 0, then we can print any composite number twice.
- If N = 0, then we can print 9*N and 8 * N, because these composite numbers have minimum difference between each other, i.e., 1.
- We can also print 15 * N and 16 * N, but we have to print any two composite numbers, so any of these are possible.
Below is the implementation of the
Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.