Project Euler

Problem 7: 10001st Prime

Calculate the 10001st prime number. Run this solution at repl.io here.

      
        from check_prime import check_prime

        p = 1 # any odd greater than this could be prime
        k = 10001 #the goal!
        i = 1 # counter, and we know 2 is prime

        while i < k:
          p += 2 #increment +2 for odds
          if check_prime(p):
            i += 1 #count the primes

        print(str(i) + "th prime number is " + str(p))
      
    

back to code menu