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
- Queries for the difference between the count of composite and prime numbers in a given range
- Find a range of composite numbers of given length
- Find a sequence of N prime numbers whose sum is a composite number
- Composite numbers with digit sum 1
- Split n into maximum composite numbers
- Product of all the Composite Numbers in an array
- Represent the given number as the sum of two composite numbers
- Sum and Product of all Composite numbers which are divisible by k in an array
- Find two numbers with the given LCM and minimum possible difference
- Sum and product of k smallest and k largest composite numbers in the array
- Program to find the percentage of difference between two numbers
- Generate a list of n consecutive composite numbers (An interesting method)
- Program to find the maximum difference between the index of any two different numbers
- Find the minimum difference between Shifted tables of two numbers
- Find the total number of composite factor for a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : AnkitRai01