Instead of checking up to num/2, we can optimize by checking up to √num:
c
Copy
Edit
#include
#include
int main() {
int num, i, isPrime = 1;
printf("Enter a number: "); https://docs.vultr.com/clang/examples/check-whether-a-number-is-prime-or-not