C++ code to find composite numbers whose difference is n


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: 11-Mar-2022

186 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements