Skip to content

find prime in range #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Prime/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@


def prime(range_from, range_to):

allList = [x for x in range(2, int(range_to)+1)]

ptr = 0
while True:
i = 2
while i * allList[ptr] <= int(range_to):
if i*allList[ptr] in allList:
allList.remove(i*allList[ptr])
i += 1
ptr += 1
if allList[ptr] ** 2 > int(range_to):
break


primeList = [x for x in allList if x > int(range_from)]
print("Prime List Between ", range_from, " and ", range_to, " is")
print(primeList)



if __name__ == "__main__":
print("Enter the range of number")
range_from = input("From: ")
range_to = input("To: ")

prime(range_from, range_to)