Implementation of prime cycle generation (initial version)