Skip to content

Commit 75d11f9

Browse files
kushalnaiduharshildarji
authored andcommitted
Correctly check for squares of primes (TheAlgorithms#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.
1 parent fa86d3d commit 75d11f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

maths/PrimeCheck.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def primeCheck(number):
22
prime = True
3-
for i in range(2, int(number**(0.5)+1), 2):
3+
for i in range(2, int(number**(0.5)+2), 2):
44
if i != 2:
55
i = i - 1
66
if number % i == 0:

0 commit comments

Comments
 (0)