﻿__author__ = 'Abhishek'

from math import sqrt


def checkifprime(value):
    for element in range(2, int(sqrt(value)+1)): #checks all factors of number up to the square root of the number
        if value % element == 0:
            return False
            break
    return True


#generates a list of primenumbers
def primenumbergenerator(x):
	counter = 1 # starts at 1 because first prime number is 2
	primelist = []
	testnumber = 3 #first non-even prime; counter starts from this number
	while counter !=x:
			if checkifprime(testnumber):
				primelist.append(testnumber)#add prime number to list
				counter+=1
			testnumber = testnumber +2 #avoids even numbers because they are composite 
	return primelist #returns a list of x prime numbers


print primenumbergenerator(10001)
