Find Composite Numbers Whose Difference is N in C++



Suppose we have a number n. We have to find two composite integers (non-prime) a and b, such that a - b = n.

So, if the input is like n = 512, then the output will be 4608 and 4096

Steps

To solve this, we will follow these steps −

print 10*n and 9*n.

Example

Let us see the following implementation to get better understanding −

#include<bits/stdc++.h>
using namespace std;
void solve(int n){
   cout<<10*n<<", "<<9*n;
}
int main(){
   int n = 512;
   solve(n);
}

Input

512

Output

5120, 4608
Updated on: 2022-03-11T06:54:57+05:30

274 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements