From 75d11f9034552685b390054a4a7083766a649caa Mon Sep 17 00:00:00 2001 From: Kushal Naidu Date: Tue, 30 Oct 2018 19:08:44 +0530 Subject: [PATCH] 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. --- maths/PrimeCheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/PrimeCheck.py b/maths/PrimeCheck.py index 79fd343db..9a75a978c 100644 --- a/maths/PrimeCheck.py +++ b/maths/PrimeCheck.py @@ -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: