C language to determine whether a number is prime or not

C language to determine whether a number is prime or not

int is_prime_number(int v)
{
    int i, f = 0;
 
    for (i = 2; i <= v/2; ++i) {
        if (v % i == 0) {
            f = 1;
            break;
        }
    }
 
    return (f == 0) ? 1 : 0;
}

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example