Design a State Sequencer using T Flip-Flops and NAND Gates that Cycles through the Prime Numbers (1, 2, 3, 5, 7) in ascending order if the select input "S" is set; Otherwise (if "S" is 0) it cycles through 0, 4, and 6.
6 and 7 are the only two states to enter/exit the cycles.
the logic portion should only use T Flip-Flops and NAND gates.