Adding a cache layer to the relatively prime algorithm.