0
私のコードは、非常に大きな数に13個の隣接する数字の最大の製品を見つけることを意図しているが、何らかの理由で、それはあなたがにyとリセット6429780.キャッピングのBigInteger番号は
public class Euler8 {
public static void main(String[]args) {
String number=//large 1000 digit number
BigInteger[] anarray=new BigInteger[13];
BigInteger product=new BigInteger("1");
BigInteger maxproduct=new BigInteger("0");
int y=0;
for(int i=0;i<number.length();i++){
anarray[y]=BigInteger.valueOf(Long.valueOf(Character.toString(number.charAt(i))));
y++;
if(i>=12){
for(BigInteger x : anarray) {
if(x.compareTo(BigInteger.ZERO)==0||x.compareTo(BigInteger.ZERO)==1) {
product = product.multiply(x);
}
}
if(product.compareTo(maxproduct)==1){
maxproduct=product;`
}
y=0;
product=BigInteger.ONE;
}
}
System.out.println(maxproduct);
}
}
あなたの質問は何ですか? – kaitoy