Quote:Are there any tested libraries for counting prime numbers?

As far as I know, counting prime numbers is not a subject such as one have created a library on this subject.

Quote:The first idea that came to my mind is matrices, but I don't know if that is the right direction.

I have no idea how counting prime cumbers is related to matrices.

The subject is so basic, that it is just about detecting prime numbers in given range, and counting them. After that, the difference between methods are how clever they are, how they avoid useless work.

https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

It's good if they were on matrices, but I will also see others.

And it's fun.