title: Finding all divisors of a number optimization
body: <p>I have written the following function which finds all divisors of a given natural number and returns them as a list:</p>
  
  <pre><code>def FindAllDivisors(x):
      divList = []
      y = 1
      while y &lt;= math.sqrt(x):
          if x % y == 0:
              divList.append(y)
              divList.append(int(x / y))
          y += 1
      return divList
  </code></pre>
  
  <p>It works really well with the exception that it's really slow when the input is say an 18-digit number. Do you have any suggestions for how I can speed it up?</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I have the following method to check for primality based on Fermat's Little Theorem:</p>
  
  <pre><code>def CheckIfProbablyPrime(x):
      return (2 &lt;&lt; x - 2) % x == 1
  </code></pre>
  
  <p>This method is really efficient when checking a single number, however I'm not sure whether I should be using it to compile all primes up to a certain boundary.</p>