A C ++ solution is asked for here, but the code presented is something else.
It should look something like this:
typedef std::vector<int> arrtyp;
int main()
{
arrtyp v = { 2, 3, 4, 6, 7 };
printout(v);
for (long i=(long)v.size()-2; i>=0; i--) {
long isCoPrimes = coPrimes(v.at(i), v.at(i+1));
if (isCoPrimes != 1) {
long l = lcm(v[i], v[i+1]);
v.erase(v.begin() + i);
v[i] = l;
}
}
std::cout << "Solution: ";
printout(v);
return 0;
}
Any missing headers and functions would have to be added.