title: Prime number finder - optimization
body: <p>I'm trying to build a prime number finder that would work as fast as possible. This is the def function that is included in the program. I'm having problems with just one detail, which I have put in {brackets} below. I have also explained the main parameters.</p>
  
  <pre><code>import math
  def is_prime(x):
      c=0      #a simple counter
      a=7      #a (+ k*6)a group of all possible deviders of the number(if 2,3 and 5 are taken away)
      b=11      #the other group
      {r=x**(1/2)}      #root of the number
      {f=math.floor(r)}       #floor of the root
      if x%2!=0 and x%3!=0 and x%5!=0:      #eliminate all multiples of 2,3 and 5
          while (c==0 and {a&lt;f}):         #while loop
                  if x%a==0 or x%b==0:
                          c+=1          #if true -&gt; will break
                  a+=6        #adding 6 to a and b (numbers that have a potential to devide
                  b+=6
          if c==0:       #if a number not divisable by anything, return number
              return x
  </code></pre>
  
  <p>This function doesn't work properly. If instead of floored squared root of my number I just replace it with x/3 it will work just fine. But the problem is that I don't want to check all the possible dividers in between x**(1/2) and x/3, because it will only slow the function, nothing else. So here is the code that works:</p>
  
  <pre><code>import math
  def is_prime(x):
  c=0
  a=7
  b=11
  if x%2!=0 and x%3!=0 and x%5!=0:
          while (c==0 and a&lt;x/3):
                  if x%a==0 or x%b==0:
                          c+=1
                  a+=6
                  b+=6
          if c==0:
              return x
  </code></pre>
  
  <p>If anyone sees the problem, help please :D</p>