Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass

JeffersGlass/primes.py Secret

Created Aug 30, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.