hi
i ve tried to solve this prob using java:
For a positive integer n, let σ2(n) be the sum of the squares of its divisors. For example,
σ2(10) = 1 + 4 + 25 + 100 = 130.
Find the sum of all n, 0 n 64,000,000 such that σ2(n) is a perfect square.
but its taking long long time to run
can anybody help??
this is my code:
Code:import java.math.*;
import static java.lang.Math.*;
public class prob211
{
public prob211()
{
BigInteger sum = BigInteger.ZERO;
for(BigInteger i = BigInteger.valueOf(1);i.compareTo(BigInteger.valueOf(64000000))<0;i=i.add(BigInteger.ONE))
{
BigInteger x = BigInteger.ZERO;
BigInteger sqsum = BigInteger.ZERO;
for(BigInteger j = BigInteger.valueOf(1);j.compareTo(BigInteger.valueOf((i.divide(BigInteger.valueOf(2))).longValue()))<=0;j=j.add(BigInteger.ONE))
{
if((i.mod(j)).equals(BigInteger.ZERO))
{
sqsum = sqsum.add(j.multiply(j));
}
}
sqsum=sqsum.add(i.multiply(i));
long y =(long) sqrt(sqsum.longValue());
for(BigInteger k= BigInteger.ONE;k.compareTo(BigInteger.valueOf(y))<=0;k=k.add(BigInteger.ONE))
{
x = x.add(((k.multiply(BigInteger.valueOf(2))).subtract(BigInteger.ONE))) ;
}
if(x.equals(sqsum))
{
sum = sum.add(i);
}
}
System.out.println(sum);
}
public static void main(String[] args)
{
new prob211();
}
}

