Please delete this thread I have found the answer myself.

Hi.
I'm making a C++ program that factors trinomials and I need to find the GCD of 3 numbers. I have a function for finding GCD with 2 numbers.

That function is:
1
2
3
4
5
6
7
8
9
10
11
12
int gcd(int number1, int number2)
{
    int c;
    while(1)
    {
  		c = number1 % number2;
  		if (c == 0)
  	  		return b;
  		number1 = number2;
  		number2 = c;
    }
}


Any idea how I could make a formula to find GCD of 3 numbers?
Thanks.
Last edited on
couldn't you just do gcd(gcd(a,b),c)?

and what is the value of "b" in your code there? It only seems to show up on that one line.
Last edited on
Never mind I don't need this.
Delete this thread now.
Topic archived. No new replies allowed.