Archive

Archive for July 2, 2019

Python: 10001st Prime



Python: 10001st Prime
Problem No.7 @ ProjectEuler

This is one of shot projects you may find on ProjectEuler, the task is find the prime No 10001, I just run my is_prime function, if the number is prime will add 1 to the counter, until we reach 10001, that will be the answer.



The Code:



# 10001st prime
# Problem 7
# Solved: Wed, 26 Jun 2019, 05:57am (GMT+3)

def is_prime(num):

result = True

for t in range (2,num):

if num%t==0 :

result= False

break

return result

p_count=0
num =0
while p_count <=10001:

num +=1

if is_prime (num):

p_count +=1

print(p_count,num)
print(num,p_count-1)






Follow me on Twitter..



Advertisements