Skip to content

Instantly share code, notes, and snippets.

@Glacier150
Last active January 22, 2024 03:15
Show Gist options
  • Save Glacier150/fb3667ac3617031cebf5a34b3cdf5c7f to your computer and use it in GitHub Desktop.
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
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
@mariano-f-r
Copy link

Genius

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment