Is Prime?
This algorithm checks that a given positive integer number is prime or not. If it is, then returns a $\mathtt{True}$, otherwise $\mathtt{False}$.
#!/usr/bin/python import math def is_prime(a): n = math.sqrt(a) for i in range(2, int(n)): if (a % i) == 0: return False return True
Example:
print(is_prime(127493299))
gives $\mathtt{True}$.
print(is_prime(127493285))
gives $\mathtt{False}$.