Skip to content

Commit 1359569

Browse files
mhayteradamant-pwn
authored andcommitted
Integers less than 2 (especially 1) are not prime.
I got a wrong answer because I copied this on a contest once. This corrects the error.
1 parent 8366f0d commit 1359569

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/algebra/primality_tests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ If it is a divisor, than $n$ is definitely not prime, otherwise it is.
2020

2121
```cpp
2222
bool isPrime(int x) {
23+
if (x<2) return false;
2324
for (int d = 2; d * d <= x; d++) {
2425
if (x % d == 0)
2526
return false;

0 commit comments

Comments
 (0)