Skip to content

Commit f9a1acd

Browse files
codingbbqIdrish LaxmidharVishal SharmaPanquesito7
authored
Issue TheAlgorithms#1536 - [BUG] check_prime.cpp returns incorrect output for 9 (TheAlgorithms#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>
1 parent 5d34de8 commit f9a1acd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

math/check_prime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool is_prime(T num) {
2929
return 0;
3030
}
3131
if (num >= 3) {
32-
for (T i = 3; (i * i) < (num); i = (i + 2)) {
32+
for (T i = 3; (i * i) <= (num); i = (i + 2)) {
3333
if ((num % i) == 0) {
3434
result = false;
3535
break;

0 commit comments

Comments
 (0)