Prime Assessment solution by HackerRank