Issue #1536 - [BUG] check_prime.cpp returns incorrect output for 9 (#1537)

Co-authored-by: Idrish Laxmidhar <idrish.l@hcl.com>
Co-authored-by: Vishal Sharma <mrvishalsharma@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
codingbbq 2021-07-22 23:38:28 +05:30 committed by GitHub
parent 5d34de836e
commit f9a1acd4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ bool is_prime(T num) {
return 0;
}
if (num >= 3) {
for (T i = 3; (i * i) < (num); i = (i + 2)) {
for (T i = 3; (i * i) <= (num); i = (i + 2)) {
if ((num % i) == 0) {
result = false;
break;