Blame view

7.py 395 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python

import sys;
import math;

def isPrime(num):

	for i in range (2, int(math.floor(math.sqrt(num)))+1):
		if ((num % i) == 0):
			return False;

	return True;

def getPrime(pos):

	if(pos == 1):
		return 2; 
	count = 1;
	num = 1;
	while(pos != count):
		num += 2;
		if(isPrime(num)):
			count += 1;

	return num;

pos = int(sys.argv[1]);
print "Result is: " + str(getPrime(pos));