forked fromTheAlgorithms/Python
- Notifications
You must be signed in to change notification settings - Fork0
Commit36828b1
[FIX] maths/PrimeCheck (TheAlgorithms#796)
Current implementation is buggy and hard to read.* Negative values were raising a TypeError due to `math.sqrt`* 1 was considered prime, it is not.* 2 was considered not prime, it is.The implementation has been corrected to fix the bugs and to enhancereadability.A docstring has been added with the definition of a prime number.A complete test suite has been written, it tests the 10 first primes, anegative value, 0, 1 and some not prime numbers.closesTheAlgorithms#7951 parent56513cb commit36828b1
1 file changed
+48
-7
lines changedLines changed: 48 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 |
| |
3 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 |
| |
5 |
| - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
6 | 50 |
| |
7 |
| - | |
8 |
| - | |
9 |
| - | |
10 |
| - | |
11 | 51 |
| |
12 | 52 |
| |
13 |
| - | |
| 53 | + | |
| 54 | + |
0 commit comments
Comments
(0)