Logo

GitLab

Sign in

Imanol-Mikel Barba Sabariego / euler

  • Back to Dashboard
  • Project
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Labels
  • Wiki
  • euler
  • 7.py
  • Adding code and License
    850d005e
    Imanol-Mikel Barba Sabariego authored
    2015-07-22 11:46:59 +0200  
    Browse Code ยป
7.py 395 Bytes
Edit Raw Blame History
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));