Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created August 30, 2020 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/2c38eefc2b8464310fb0162803177b7c to your computer and use it in GitHub Desktop.
Save JeffersGlass/2c38eefc2b8464310fb0162803177b7c to your computer and use it in GitHub Desktop.
from time import time
from math import floor, sqrt
from gpiozero import LED
redLed = LED(20)
redLed.off()
greenLed = LED(12)
greenLed.off()
def isPrime(n):
for i in range (2,floor(sqrt(n))+1):
if n/i == floor(n/i): return False
return True
def listPrimesUpTo(num):
for i in range (2,num):
print(str(i) + " ", end = "")
if isPrime(i): print ("is Prime")
else: print ("is Composite")
redLed.on()
listPrimesUpTo(3000)
redLed.off()
greenLed.on()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment