You are provided an integer . Your task is to determine the largest integer () that is a coprime of given number.
Solution#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int num;
cin >> num;
for(int i=num-2;i>0;i--)
{
if( __gcd(num,i)==1)
{
cout<<i;
break;
}
}
}
if you have any problem in this code, take a screen shot and contact with Rishabh Chaubey.
Post a Comment