Skip to content

Commit c8c2f99

Browse files
authored
Merge pull request keon#66 from mathagician/issue-56
keon#58 | Correct the logic of Prime testing function in math/test_primt.py
2 parents 238e68b + 5055f2d commit c8c2f99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

math/prime_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ def prime_test(n):
1010
return True
1111
if n%2==0 or n%3==0:
1212
return False
13-
j = 6
14-
while((j-1)*(j-1) <= n):
15-
if n%(j-1)==0 or n%(j+1)==0:
13+
j = 5
14+
while(j*j <= n):
15+
if n%(j)==0 or n%(j+2)==0:
1616
return False
1717
j += 6
1818
return True

0 commit comments

Comments
 (0)