Blame view

10.py 375 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
#!/usr/bin/python

import sys;
import math;

def isPrime(num):

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

	return True;

def sumPrimes(num):

	sum = 0;
	for i in range (1,num):
		if(isPrime(i)):
			sum += i;

	return sum;

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