Implementing a prime number counting algorithm