mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 06:33:44 +00:00
Correctly check for squares of primes (#549)
As the for-loop was looping by two numbers, it would stop at 1 number less than the root of prime squares, resulting it in incorrectly classifying the squares as prime numbers. Incrementing the loop ensures the next number is also considered resulting in accurate classification.
This commit is contained in:
parent
fa86d3d954
commit
75d11f9034
|
@ -1,6 +1,6 @@
|
|||
def primeCheck(number):
|
||||
prime = True
|
||||
for i in range(2, int(number**(0.5)+1), 2):
|
||||
for i in range(2, int(number**(0.5)+2), 2):
|
||||
if i != 2:
|
||||
i = i - 1
|
||||
if number % i == 0:
|
||||
|
|
Loading…
Reference in New Issue
Block a user