Skip to content

Instantly share code, notes, and snippets.

@Wqrld
Created May 27, 2022 15:24
Show Gist options
  • Save Wqrld/94b5c63638ea69f52eb0d314dae5dd07 to your computer and use it in GitHub Desktop.
Save Wqrld/94b5c63638ea69f52eb0d314dae5dd07 to your computer and use it in GitHub Desktop.
arr = {}
def main():
print("Range: ")
r = int(input())
# For each number 0-r
# If number not yet marked off
# mark all multiples of the number that are under r
for i in range(2, r):
if i not in arr:
x = 2
while i * x < r:
arr[i * x] = True
x = x + 1
# Print out our primes
for i in range(2, r):
if i not in arr:
print(i)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment