title: Get factors of a number
body: <p>I need to get two factors ( x, y ) of a given number ( n ) such that:</p>
  
  <ul>
  <li>x * y &lt;= n</li>
  <li>x * y should be as close to n as possible</li>
  <li>x and y should be as close to each other as possible.</li>
  </ul>
  
  <p>Examples:</p>
  
  <ul>
  <li>n = 16 => x = 4, y = 4</li>
  <li>n = 17 => x = 4, y = 4</li>
  <li>n = 18 => x = 6, y = 3</li>
  <li>n = 20 => x = 5, y = 4</li>
  </ul>
  
  <p>Any language will do but preferably php.</p>
  
  <p>EDIT -- CLARIFICATION</p>
  
  <p>I want to create a rectangle, x units wide * y units tall such that its area is as close to n as possible. x and y must be integers. If n is a prime number then factors of n - 1 are acceptable.</p>