title: Find the greatest factor of a number (other than itself)
body: <p>What is an optimal way to find the greatest factor of a number (other than itself)? So far, I've got this:</p>
  
  <pre><code>function biggestFactor(num) {
    if (num % 2 == 0) return num / 2;
    var result;
    for (var i = 1, m = Math.floor(num / 2); i &lt; m; i++) {
      if (num % i == 0) result = i;
    }
    return result;
  }
  
  greatestFactor(1024); // 512
  greatestFactor(1025); // 205
  greatestFactor(1026); // 513
  greatestFactor(1027); // 79
  </code></pre>
  
  <p>This is obviously not so efficient. What are other ways to solve this?</p>