Skip to content

Instantly share code, notes, and snippets.

@maxfire2008
Last active November 11, 2021 22:57
Show Gist options
  • Save maxfire2008/d9a1f8aa0494031d8100b06f89b2fdc7 to your computer and use it in GitHub Desktop.
Save maxfire2008/d9a1f8aa0494031d8100b06f89b2fdc7 to your computer and use it in GitHub Desktop.
prime generator
# curl -L https://gist.githubusercontent.com/maxfire2008/d9a1f8aa0494031d8100b06f89b2fdc7/raw/ --output primegen_d9a1f8aa0494031d8100b06f89b2fdc7.py && python3 primegen_d9a1f8aa0494031d8100b06f89b2fdc7.py
import random
def primeCheck(n):
if n == 1 or n == 0 or (n % 2 == 0 and n > 2):
return False
else:
for o in range(3, int(n ** (1 / 2)) + 1, 2):
if n % o == 0:
return False
return True
choices = []
for x in range(int(input("Start:")),int(input("End:"))+1):
if primeCheck(x):
choices.append(x)
random.shuffle(choices)
for x in range(int(input("GenCount:"))):
print(choices.pop())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment