Skip to content

Instantly share code, notes, and snippets.

@tusharhero
Last active August 4, 2022 15:32
Show Gist options
  • Save tusharhero/77b4d317739dfa9db7beeceaae68bf14 to your computer and use it in GitHub Desktop.
Save tusharhero/77b4d317739dfa9db7beeceaae68bf14 to your computer and use it in GitHub Desktop.
prime numbers generator
#A python script to generate prime numbers
def getfactors(n):
factors = []
for num in range(1,n+1):
if n%num == 0:
factors.append(num)
return factors
def isitprime(n):
return len(getfactors(n)) == 2
def getprimes(r):
primes=[]
for n in range(1,r):
if isitprime(n) == True:
primes.append(n)
return primes
print(getprimes(100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment