10200. Prime Time – Solution http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1141 View the code on Gist.