Add problem 17 solution in Java.