Skip to content

Commit f069c20

Browse files
authored
Easier Solution To Problem 7
1 parent 9714aa3 commit f069c20

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Project Euler/Problem 07/sol2.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the Nth prime number?
2+
def isprime(number):
3+
for i in range(2,int(number**0.5)+1):
4+
if number%i==0:
5+
return False
6+
return True
7+
n = int(input('Enter The N\'th Prime Number You Want To Get: ')) # Ask For The N'th Prime Number Wanted
8+
primes = []
9+
num = 2
10+
while len(primes) < n:
11+
if isprime(num):
12+
primes.append(num)
13+
num += 1
14+
else:
15+
num += 1
16+
print(primes[len(primes) - 1])

0 commit comments

Comments
 (0)