Problem 21: Evaluate the sum of all amicable pairs under 10000.
import java.util.HashMap;
class runner
{
public static int d(int n){
int sum = 0;
for(int i = 2; i<= Math.floor(Math.sqrt(n));i++){
if(n%i == 0){
int div = n/i;
if(div != i){
sum += i; sum+=div;
}
}
}
return sum+1;
}
public static void main (String[] args) throws java.lang.Exception
{
long time = System.currentTimeMillis();
int n = 10000;
HashMap cache = new HashMap();
int sum = 0;
for(int i=1;i