title: No multiples in Pythagorean triplets
body: <p>Based on the book Physical Modeling in Matlab (available online <a href="http://greenteapress.com/wp/physical-modeling-in-matlab-2e/" rel="nofollow noreferrer">here</a>) I have the following functions to find Pythagorean triplets</p>
  
  <pre><code># Function isintegral. Checks whether a number is integer
  
  function res = isintegral(x)
      if round(x) == x
          res = 1;
      else
          res = 0;
      end
  end
  
  # function hypotenuse computes the length 
  # of the hypotenuse of a right triangle if 
  # the lengths of the adjacent sides are a and b
  
  function res = hypotenuse(a,b)
  res = sqrt(a^2+b^2);
  end
  
  # function find_triples
  # A function to search for “Pythagorean triples”
  
  function res = find_triples (n)
      for a = 1:n
          for b = a:n 
              c = hypotenuse(a,b);
              flag = isintegral(c);
              if flag
                  [a,b,c]
              end
          end
      end
  end
  </code></pre>
  
  <p>In this way</p>
  
  <pre><code>&gt;&gt; find_triples(15)
  ans =
  
     3   4   5
  
  ans =
  
      5   12   13
  
  ans =
  
      6    8   10
  
  ans =
  
      8   15   17
  
  ans =
  
      9   12   15
  </code></pre>
  
  <p>Apart from the triples 5, 12, 13 and 8, 15, 17 the others are just multiples of the 3, 4, 5 triangle. So how can one modify the code so that it returns only <code>[3,4,5]</code>, <code>[5,12,13]</code>, <code>[8,15,17]</code> if we execute <code>find_triples(15)</code> ?</p>