python program to find prime number n by seeing if they can divide evenly into prime numbers less that the squareroot of n
<p>How do I make this return the right results for primes less than 10 ?</p>

<pre><code>from math import *

def isPrime(n):

i = [c for c in range(int(sqrt(n)),0,-1) if c % 2 != 0 and c &gt; 1 ]

for x in i: 
    if n % x == 0:
        return print('%s is not prime' % (n))
return print('%s is prime number' %(n))


def main():

loopCnt = 'y'
while loopCnt != 'n':
    n = int(input('Enter a integer greater than 2: '))
    isPrime(n)


    loopCnt = input('Enter any key to try again or enter n to exit').strip().lower()


main()
</code></pre>

<p>It is not giving the desired output</p>

<pre><code>i = [c for c in range(int(sqrt(n)),0,-1) if c % 2 != 0]
</code></pre>

<p>This code is skipping all even divisors. This is correct for <em>most</em> divisors, but it incorrectly skips 2, so it will misclassify even numbers!</p>

<p>You need to make an exception for 2, either in the filter or by adding a special case to check whether <code>n</code> is an even number greater than 2.</p>

<p>(As an aside, checking divisors in reverse order will slow you down. Small divisors are more common in randomly chosen composite numbers than large ones.)</p>

python