mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +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
@ -13,15 +13,15 @@ References:
|
||||
"""
|
||||
|
||||
|
||||
def isprime(number: int) -> bool:
|
||||
def is_prime(number: int) -> bool:
|
||||
"""
|
||||
Determines whether the given number is prime or not
|
||||
|
||||
>>> isprime(2)
|
||||
>>> is_prime(2)
|
||||
True
|
||||
>>> isprime(15)
|
||||
>>> is_prime(15)
|
||||
False
|
||||
>>> isprime(29)
|
||||
>>> is_prime(29)
|
||||
True
|
||||
"""
|
||||
|
||||
@ -76,7 +76,7 @@ def solution(nth: int = 10001) -> int:
|
||||
primes: list[int] = []
|
||||
num = 2
|
||||
while len(primes) < nth:
|
||||
if isprime(num):
|
||||
if is_prime(num):
|
||||
primes.append(num)
|
||||
num += 1
|
||||
else:
|
||||
|
@ -15,15 +15,15 @@ import itertools
|
||||
import math
|
||||
|
||||
|
||||
def prime_check(number: int) -> bool:
|
||||
def is_prime(number: int) -> bool:
|
||||
"""
|
||||
Determines whether a given number is prime or not
|
||||
|
||||
>>> prime_check(2)
|
||||
>>> is_prime(2)
|
||||
True
|
||||
>>> prime_check(15)
|
||||
>>> is_prime(15)
|
||||
False
|
||||
>>> prime_check(29)
|
||||
>>> is_prime(29)
|
||||
True
|
||||
"""
|
||||
|
||||
@ -39,7 +39,7 @@ def prime_generator():
|
||||
|
||||
num = 2
|
||||
while True:
|
||||
if prime_check(num):
|
||||
if is_prime(num):
|
||||
yield num
|
||||
num += 1
|
||||
|
||||
|
Reference in New Issue
Block a user