title: How to find the GCD of three numbers within a single method
body: <p>I've got to ensure that the GCD between 3 numbers is no greater than 1.</p>
  
  <p>Here's the code I have so far for the method:</p>
  
  <pre><code>private int greatestCommonFactor(int a, int b, int c)
  {
      for(int n = 0; n &lt;= number; n++)
      {
          if()
      }
  
      return 1;
  }
  </code></pre>
  
  <p>the <code>return 1</code> was already there when I started working on the lab. How can I make sure that the GCD is no more than 1? And return all three integers?</p>
  
  <p>Here's the remainder of the code if it helps in figuring out what needs to be done:</p>
  
  <pre><code>import static java.lang.System.*;
  
  public class Triples
  {
   private int number;
  
  public Triples()
  {
      this(0);
  }
  
  public Triples(int num)
  {
      number = num;
  }
  
  public void setNum(int num)
  {
      number = num;
  }
  
  private int greatestCommonFactor(int a, int b, int c)
  {
      for(int n = 0; n &lt;= number; n++)
      {
          if()
      }
  
      return 1;
  }
  
  public String toString()
  {
      String output="";
      int max = number;
      for(a = 1; a &lt;= max; a++)
      {
          for(b = a +1; b &lt;= max; b++)
          {
              for(c = b + 1; c &lt;= max; c++)
              {
                  if(Math.pow(a, 2)+ Math.pow(b, 2)== Math.pow(c, 2))
                  {
                      if((a%2==1 &amp;&amp; b%2==0)|| (a%2==0 &amp;&amp; b%2==1))
                  }
              }
          }
      }
  
  
      return output+"\n";
  }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is my new coding for the same lab: </p>
  
  <pre><code>import static java.lang.System.*;
  
  public class Triples
  {
   private int number;
  
  public Triples()
  {
      this(0);
  }
  
  public Triples(int num)
  {
      number = num;
  }
  
  public void setNum(int num)
  {
      number = num;
  }
  
  private int greatestCommonFactor(int a, int b, int c)
  {
      for(int n = 0; n &lt;= number; n++)
      {
      int max = number;
      for(a = 1; a &lt;= max; a++)
      {
          a = n;
          for(b = a +1; b &lt;= max; b++)
          {
              b =n;
              for(c = b + 1; c &lt;= max; c++)
              {
                  c = n;
                  if(Math.pow(a, 2)+ Math.pow(b, 2)== Math.pow(c, 2))
                  {
                      if((a%2==1 &amp;&amp; b%2==0)|| (a%2==0 &amp;&amp; b%2==1))
                      {
                          if(a%2&lt;=1 &amp;&amp; b%2&lt;=1 &amp;&amp; c%2&lt;=1)
                          {
                              return 1;
                          }
                      }
                  }
              }
          }
      }
      }
  
      return 1;
  }
  
  public String toString()
  {
      String output="";
      output = greatestCommonFactor(a, b, c);
  
  
      return output+"\n";
  }
  }
  </code></pre>