def nthprime():
    counter = 1  #here counter keeps the track of the number of the prime generated by the program
    num = 1  #this is the number which keeps the track of iteration
    found = False    #boolean to keep the loop on until we get the output we looking for

    while not found:
        num += 2    #num= 1 added 2 will be 3 and so on. Hence, generates odd nmber only as all odds are primes except 1
        check = 0
        for i in range(1,num+1):
            if num%i == 0: check += 1
        if check == 2:  #here check remains 2 only and only for primes as primes are divided exactly by 1 and themselves only
            counter += 1
        if counter == 1000:
            found = True  #here the loop breaks when found is true
    print (str(counter) + " th prime number is " + str(num))
nthprime()



#the program can be used to print any nth prime number that you have been looking after passing a parameter and making somechanges
#the program has longer running time so in order to get 2000th prime number can take much more time and so longer for other later prime numbers

import math    #import some math modules which we will use here

def nthprime_log(n):
    count = 0
    sum = math.log(2) #as 2 is first prime and not included the following loop
    for num in range(3,n,2):
        check = 0
        for divider in range(2,int(math.sqrt(num))+1):
            if num%divider == 0: check += 1
            count += 1
        if check == 2:  #here check remains 2 only and only for primes as primes are divided exactly by 1 and themselves only
            sum = sum + math.log(num)
    print ("Sum of logs of primes equals " + str(sum))
    print ("Number is " + str(n))
    print ("Ratio of sums of logs of prime to number n will equal to " + str(sum/n))
nthprime_log(int(raw_input("Enter the number up to which log of primes is to be summed up ")))

#Some observation of this problem
#greater the number you enter the closer the value of the ratio
#the ratio rises non monotonically
