We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0c9b1b8 commit 72407e2Copy full SHA for 72407e2
project_euler/problem_058/sol1.py
@@ -33,6 +33,7 @@
33
count of current primes.
34
35
"""
36
+from math import isqrt
37
38
39
def isprime(n: int) -> int:
@@ -48,11 +49,12 @@ def isprime(n: int) -> int:
48
49
if n == 1:
50
return 0
51
- i = 2
52
- while i * i <= n:
+ if n % 2 == 0 and n > 2:
53
+ return 0
54
+
55
+ for i in range(3, isqrt(n) + 1, 2):
56
if n % i == 0:
57
- i = i + 1
58
return 1
59
60
0 commit comments