HackerRank Java Loops II problem solution - TheCScience