mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Remove duplicate is_prime related functions (#5892)
* Fixes (#5434) * Update ciphers.rabin_miller.py maths.miller_rabin.py * Fixing ERROR maths/miller_rabin.py - ModuleNotFoundError and changing project_euler's isPrime to is_prime function names * Update sol1.py * fix: try to change to list * fix pre-commit * fix capital letters * Update miller_rabin.py * Update rabin_miller.py Co-authored-by: John Law <johnlaw.po@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1d3d18bcd2
commit
1400cb86ff
@@ -25,7 +25,7 @@ def rabinMiller(num: int) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def isPrime(num: int) -> bool:
|
||||
def is_prime_low_num(num: int) -> bool:
|
||||
if num < 2:
|
||||
return False
|
||||
|
||||
@@ -213,11 +213,11 @@ def isPrime(num: int) -> bool:
|
||||
def generateLargePrime(keysize: int = 1024) -> int:
|
||||
while True:
|
||||
num = random.randrange(2 ** (keysize - 1), 2 ** (keysize))
|
||||
if isPrime(num):
|
||||
if is_prime_low_num(num):
|
||||
return num
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
num = generateLargePrime()
|
||||
print(("Prime number:", num))
|
||||
print(("isPrime:", isPrime(num)))
|
||||
print(("is_prime_low_num:", is_prime_low_num(num)))
|
||||
|
||||
Reference in New Issue
Block a user