Hi,
I'm trying to solve problem 32 of project euler in Java but I'm not getting the correct answer. I'm getting the answer of the following program as 48146. Could anyone please tell me what's wrong I'm doing here and how can I solve that problem?
Here's the code through which I'm trying to solve that problem:
public class Euler32
{
public static boolean checkValue(char c,String s,int j)
{
for(int i=j+1;i<s.length();i++)
if(c==s.charAt(i)) return true;
return false;
}
public static void main(String[] args)
{
long total=0;
long sum=0;
for(int i1=40;i1<=999;i1++)
{
for(int j=130;j<=9999;j++)
{
sum=i1*j;
String s=i1+""+j+""+sum;
if(s.length()!=9) continue;
else
{
for(int i=0;i<s.length()-1;i++)
{
if(checkValue(s.charAt(i),s,i))
break;
if(i+1==s.length()-1) total+=sum;
}
}
}
}
System.out.println("Total sum is: "+total);
}
}