AI Features

Solution: Is the Number Prime

We'll cover the following...
C
#include <stdio.h>
int isPrime(int n)
{
if (n <= 1) return 0;
int i;
for (i = 2; (i * i) <= n; i++)
{
if (n % i == 0) return 0;
}
return 1;
}
int main(void)
{
int n = 10;
printf("%d\n", isPrime(n));
return 0;
}

Below is the explanation of the solution:

    ...