$\mathfrak{Mini}$ $\mathbb{Wiki}$

1. June 2020 mozgan   

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}$.

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



gives $\mathtt{True}$.


gives $\mathtt{False}$.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies