Witam serdecznie,
jak już wspomniałem mam problem z klasą BigInteger, który polega na tym, że zwracany przez nią wynik jest błędny (wynosi tyle co w typie long, czyli ). Oto kod programu:
import java.math.BigInteger;
public class problem2
{
public static void main(String[] args)
{
BigInteger sum = BigInteger.valueOf(0);
long tab[] = new long[4000000];
tab[0] = 1;
tab[1] = 2;
for(int x = 2; x < 4000000; ++x)
{
tab[x] = tab[x - 1] + tab[x - 2];
}
for(int x = 0; x < 4000000; ++x)
{
BigInteger suma = BigInteger.valueOf(0);
BigInteger tablica = BigInteger.valueOf(tab[x]);
suma = suma.add(tablica);
sum = suma;
}
System.out.println(sum);
}
}