Problem12.java adde, not optimized yet