Implemented prime to k gen.