Skip to content

Commit e07f4d1

Browse files
committed
Fix is_prime: add proper type hints and import math for SHA-256 implementation
1 parent f2e9d25 commit e07f4d1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ciphers/sha256.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def int_to_big_endian_bytes(value: int) -> bytes:
210210
# =============================================================================
211211

212212

213-
def is_prime(n: int) -> bool:
213+
def is_prime(num_to_test: int) -> bool:
214214
"""
215215
Returns True if n is a prime number.
216216
Uses trial division up to floor(sqrt(n)).
@@ -227,9 +227,9 @@ def is_prime(n: int) -> bool:
227227
>>> is_prime(0)
228228
False
229229
"""
230-
if n < 2:
230+
if num_to_test < 2:
231231
return False
232-
return all(n % f != 0 for f in range(2, math.isqrt(n) + 1))
232+
return all(num_to_test % f != 0 for f in range(2, math.isqrt(num_to_test) + 1))
233233

234234

235235
def first_n_primes(count_primes: int):

0 commit comments

Comments
 (0)