BigInteger b1 = new BigInteger("7");
BigInteger b2 = new BigInteger("3");
System.out.println(b1.gcd(b2));
System.out.println(Arrays.toString(b1.divideAndRemainder(b2)));
BigInteger b = BigInteger.ONE;
System.out.println(b.isProbablePrime(7));
System.out.println(b.negate());
System.out.println(b.not());
System.out.println(b.xor(BigInteger.ONE));
System.out.println(b.gcd(BigInteger.ONE));
System.out.println(b.xor(BigInteger.TEN));
System.out.println(BigInteger.probablePrime(7, new Random()));
System.out.println("");
BigInteger bigInteger = (new BigInteger("11111"));
System.out.println(bigInteger);
System.out.println(Integer.toBinaryString(bigInteger.intValue()));
System.out.println(bigInteger.toString(2));
bigInteger = bigInteger.clearBit(2);
System.out.println(bigInteger);
System.out.println(Integer.toBinaryString(bigInteger.intValue()));
System.out.println(bigInteger.toString(2));
BigInteger i = BigInteger.valueOf(50).pow(100);
System.out.println(i.toString());
System.out.println(i.toString(2));
BigInteger bi = new BigInteger("2");
bi = bi.pow(23000);
System.out.println(bi);
import java.math.BigInteger;
import java.util.ArrayList;
public class FibonacciMemoized {
private static ArrayList<BigInteger> fibCache = new ArrayList<BigInteger>();
static {
fibCache.add(BigInteger.ZERO);
fibCache.add(BigInteger.ONE);
}
public static BigInteger fib(int n) {
if (n >= fibCache.size()) {
fibCache.add(n, fib(n-1).add(fib(n-2)));
}
return fibCache.get(n);
}
public static void main(String[] args) {
System.out.println(fib(5));
System.out.println(fibCache);
}
}
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |