[ create a new paste ] login | about

Link: http://codepad.org/X018omzZ    [ raw code | fork ]

Python, pasted on Dec 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def prime():
    i = 2 #the first index
    numToTest = 5 #the first candidate prime
    listOfPrimes = [] #list of primes
    for i in range (2, 1001):
        if (numToTest-1)%6 == 0:
            listOfPrimes.append(numToTest) #it's prime. put in list
            numToTest += 2 #go to next odd number
            i += 1 #go to next index
        elif (numToTest+1)%6 == 0:
            listOfPrimes.append(numToTest) #it's prime. put in list
            i += 1 #go to next index
            numToTest += 2 #go to next odd number
        else:
            numToTest += 2 #go to next odd number
    print listOfPrimes[-1]


Output:
No errors or program output.


Create a new paste based on this one


Comments: