AllAlgorithms / c

Implementation of All ▲lgorithms in C Programming Language
https://github.com/AllAlgorithms/c
MIT License
1.44k stars 520 forks source link

Update is_prime.c #410

Closed JoyM268 closed 9 months ago

JoyM268 commented 10 months ago

I am creating a pull request for update to an algorithm. The updated program only checks numbers from 2 to the square root of the given number, instead of checking all numbers from 2 to the given number. This is because a number is prime if and only if it is not divisible by any number less than or equal to its square root. This makes the program more efficient, especially for large numbers.