📜  prime check in - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:34.361000             🧑  作者: Mango

代码示例1
int isPrime(long long number) {

    if (number == 0 || number == 1 || (number % 2 == 0 && number > 2)) {
        return 0;
    }

    else {
        for (long long i=3; i <= (long long)sqrt(number)+1; i++) {
            if (number % i == 0) {
                return 0;
            }
        }
        return 1;
    }
}