I am working on the greatest common divisor (gcd), previously I have already declare a = 667 and c = 140 and now I am trying to get the (gcd) working. The answer to this is 1. Here is my code:
Is this the right code for (gcd). If so I find it hard to display on the screen as once compile it then disappear. Is there a way that can make g display itself such asCode:int gcd(int a, int c);
{
int g;
g = a;
while (a%g!=0||c%g!=0)
{
g--;
}
return g;
}
Code:cout << g << endl;