Last active
January 22, 2024 03:15
-
-
Save Glacier150/fb3667ac3617031cebf5a34b3cdf5c7f to your computer and use it in GitHub Desktop.
Returns list of all prime numbers up to and including 'n' maximum bound
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime(n): | |
sieve = [True for x in range(n+1)] | |
primes = [] | |
for num in range(2, n+1): | |
if sieve[num] == True: | |
primes.append(num) | |
for multiple in range(num, n+1, num): | |
sieve[multiple] = False | |
return primes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Genius