File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def sieve_of_eratosthenes(n):
2929
p = 2
3030

3131
while p * p <= n:
32-
# if p is not marked as False, this it is a prime
32+
# if p is not marked as False, it is a prime
3333
if primes[p]:
3434
# mark all the multiples of number as False
3535
for i in range(p * 2, n + 1, p):
3636
primes[i] = False
3737
p += 1
3838

3939
# getting all primes
40-
primes = [element for element in range(2, n) if primes[element]]
40+
primes = [element for element in range(2, n + 1) if primes[element]]
4141

4242
return primes
4343

Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_lcm_using_gcd(self):
1717

1818
class TestSieveOfEratosthenes(unittest.TestCase):
1919
def test_sieve_of_eratosthenes(self):
20-
self.assertEqual(sieve_of_eratosthenes.sieve_of_eratosthenes(10), [2, 3, 5, 7])
20+
self.assertEqual(sieve_of_eratosthenes.sieve_of_eratosthenes(11), [2, 3, 5, 7, 11])
2121

2222
class TestFactorial(unittest.TestCase):
2323
def test_factorial(self):

0 commit comments

Comments
 (0)