Answers for "wap to check given number is prime or composite using function in c"

C
4

prime check in c

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;
	}
}
Posted by: Guest on February-07-2021

Code answers related to "wap to check given number is prime or composite using function in c"

Code answers related to "C"

Browse Popular Code Answers by Language