@@ -0,0 +1,1099 @@
+import java.util.*;%0A%0Apublic class amicable_numbers %7B%0A%09public static void main(String%5B%5D args) %7B%0A%09%09ArrayList%3CInteger%3E amicable = new ArrayList%3CInteger%3E();%0A%0A%09%09for (int i=1; i%3C=10000; i++) %7B%0A%09%09%09ArrayList%3CInteger%3E factors = getFactors(i);%0A%09%09%09int sum=0;%0A%09%09%09for (Integer factor : factors) %7B%0A%09%09%09%09sum += factor.intValue();%0A%09%09%09%7D%0A%09%09%09if (sum != i) %7B%0A%09%09%09%09ArrayList%3CInteger%3E factors2 = getFactors(sum);%0A%09%09%09%09int sum2 = 0;%0A%09%09%09%09for (Integer factor : factors2) %7B%0A%09%09%09%09%09sum2 += factor.intValue();%0A%09%09%09%09%7D%0A%09%09%09%09if (sum2 == i) %7B%0A%09%09%09%09%09amicable.add(new Integer(i));%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09int total=0;%0A%09%09for (Integer num : amicable) %7B%0A%09%09%09total += num.intValue();%0A%09%09%7D%0A%0A%09%09System.out.println(total);%0A%09%7D%0A%0A%09public static ArrayList%3CInteger%3E getFactors(int in) %7B%0A%09%09ArrayList%3CInteger%3E factors = new ArrayList%3CInteger%3E();%0A%09%09factors.add(new Integer(1));%0A%09%09int limit = (int)Math.ceil(Math.sqrt(in));%0A%09%09for (int i=2; i%3C=limit; i++) %7B%0A%09%09%09if (in %25 i == 0) %7B%0A%09%09%09%09factors.add(new Integer(i));%0A%09%09%09%09factors.add(new Integer(in/i));%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09//uniq%0A%09%09Set list = new HashSet(factors);%0A%09%09factors = new ArrayList%3CInteger%3E(list);%0A%09%09return factors;%0A%09%7D%0A%7D

amicable numbers: java