Related Articles
Find two Composite Numbers such that there difference is N
• Last Updated : 18 Mar, 2021

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.
Examples:

```Input: N = 4
Output: X = 36, Y = 32

Input: N = 1
Output: X = 9, Y = 8```

Approach

• 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

## C++

 `#include ``using` `namespace` `std;``// C++ code to Find two Composite Numbers``// such that there difference is N` `// Function to find the two composite numbers``void` `find_composite_nos(``int` `n)``{``    ``cout << 9 * n << ``" "` `<< 8 * n;``}` `// Driver code``int` `main()``{``    ``int` `n = 4;` `    ``find_composite_nos(n);` `    ``return` `0;``}`

## Java

 `// Java code to Find two Composite Numbers``// such that there difference is N``class` `GFG``{` `    ``// Function to find the two composite numbers``    ``static` `void` `find_composite_nos(``int` `n)``    ``{``        ``System.out.println(``9` `* n + ``" "` `+ ``8` `* n);``    ``}``    ` `    ``// Driver code``    ``public` `static` `void` `main (String[] args)``    ``{``        ``int` `n = ``4``;``    ` `        ``find_composite_nos(n);``    ``}``}` `// This code is contributed by AnkitRai01`

## Python3

 `# Python3 code to Find two Composite Numbers``# such that their difference is N` `# Function to find the two composite numbers``def` `find_composite_nos(n) :` `    ``print``(``9` `*` `n, ``8` `*` `n);` `# Driver code``if` `__name__ ``=``=` `"__main__"` `:` `    ``n ``=` `4``;` `    ``find_composite_nos(n);` `# This code is contributed by AnkitRai01`

## C#

 `// C# code to Find two Composite Numbers``// such that there difference is N``using` `System;` `class` `GFG``{` `    ``// Function to find the two composite numbers``    ``static` `void` `find_composite_nos(``int` `n)``    ``{``        ``Console.WriteLine(9 * n + ``" "` `+ 8 * n);``    ``}``    ` `    ``// Driver code``    ``public` `static` `void` `Main()``    ``{``        ``int` `n = 4;``    ` `        ``find_composite_nos(n);``    ``}``}` `// This code is contributed by AnkitRai01 `

## Javascript

 ``
Output:
`36 32`

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.

My Personal Notes arrow_drop_up
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}