Look at this pdf, it has a solved minimized 4-bit input prime detector.
http://www.engr.usask.ca/classes/EE/232/EE232_2011/notes/04_combinational%20logic_part2.pdf
Use an LED for giving the output (they say to convert in to a circuit :lol::lol:). Don't need to use a CCD.