Created
August 3, 2020 14:39
-
-
Save eli2and40/a19586dd38ba204ca4962018e460ff43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def primes1(n): | |
"""Generates a list of the first n primes. If the input is not an integer it will be converted to one | |
Dependencies: N/A | |
In: (number) | |
Out: list""" | |
# pwimes = list(x for x in range(n) if x > 1 and all(x%y for y in range(2, min(x, 11)))) | |
n = int(n) - 1 | |
bank = [] | |
track = 2 | |
while len(bank)<n+1: | |
if all(track%y for y in range(2,min(track,11))): | |
bank.append(track) | |
track += 1 | |
return list(set(bank)) | |
def primes2(n): | |
"""Generates a list of primes with value lower than the input integer | |
Dependencies: N/A | |
In: (integer) | |
Out: list""" | |
pwimes = list({x for x in range(n) if x > 1 and all(x%y for y in range(2, min(x, 11)))}) | |
return list(pwimes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment