[37] C

One way to improve is to cache first 100 (or so) primes and use binary
search or hash to search.