@Status(stage=PRODUCTION, unitTests=COMPLETE) @Review(by="Kees Schotanus", at="2009-09-28") @ThreadSafety(level=IMMUTABLE) public class CBigInteger extends BigInteger
Modifier and Type | Class and Description |
---|---|
static class |
CBigInteger.FibonacciIterator
Iterator suitable for iterating over all the Fibonacci numbers in sequence.
|
Modifier and Type | Field and Description |
---|---|
static BigInteger |
FIVE
The constant value 5.
|
static BigInteger |
FOUR
The constant value 4.
|
static BigInteger |
THREE
The constant value 3.
|
static BigInteger |
TWO
The constant value 2.
|
ONE, TEN, ZERO
Constructor and Description |
---|
CBigInteger(BigInteger value)
Constructs a new CBigInteger from the supplied BigInteger value.
|
CBigInteger(String value)
Constructs a new CBigInteger from the supplied String value.
|
Modifier and Type | Method and Description |
---|---|
static List<BigInteger> |
computeCollatzConjecture(BigInteger number)
Computes Collatz Conjecture.
|
BigInteger |
factorial()
Computes the factorial of this CBigInteger.
|
static BigInteger |
fibonacci(int x)
Computes Fibonacci number x.
|
static CBigInteger.FibonacciIterator |
fibonacciIterator()
Creates a Fibonacci Iterator that allows you to iterate over all the Fibonacci numbers in sequence.
|
boolean |
isFibonacci()
Determines whether this CBigInteger represents a number that occurs in the row of Fibonacci numbers.
|
boolean |
isPrime()
Determines whether this CBigInteger is a prime.
|
BigInteger |
squareRoot()
Computes the square root of this CBigInteger.
|
abs, add, and, andNot, bitCount, bitLength, byteValueExact, clearBit, compareTo, divide, divideAndRemainder, doubleValue, equals, flipBit, floatValue, gcd, getLowestSetBit, hashCode, intValue, intValueExact, isProbablePrime, longValue, longValueExact, max, min, mod, modInverse, modPow, multiply, negate, nextProbablePrime, not, or, pow, probablePrime, remainder, setBit, shiftLeft, shiftRight, shortValueExact, signum, subtract, testBit, toByteArray, toString, toString, valueOf, xor
byteValue, shortValue
public static final BigInteger TWO
public static final BigInteger THREE
public static final BigInteger FOUR
public static final BigInteger FIVE
public CBigInteger(String value)
value
- Value to convert to a CBigInteger.NumberFormatException
- When the supplied value is not a valid integer.public CBigInteger(BigInteger value)
value
- The BigInteger to convert to a CBigInteger.public boolean isPrime()
public BigInteger factorial()
CLong.factorial(int)
public BigInteger squareRoot()
ArithmeticException
- When this object has a negative value.public static List<BigInteger> computeCollatzConjecture(BigInteger number)
number
- The number to compute Collatz Conjecture for.public static BigInteger fibonacci(int x)
#0: 0 By definition
#1: 1 By definition
#2: 1 For all others it is the sum of the previous two numbers.
#3: 2
#4: 3
#5: 5
#6: 8
#7: 13
#8: 21
#9: 34
This method calculates the Fibonacci numbers in sequence and can be expensive for large values of x.x
- The Fibonacci number to compute.IllegalArgumentException
- When the supplied x value is < 0.public static CBigInteger.FibonacciIterator fibonacciIterator()
public boolean isFibonacci()
Copyright © 2008–2018. All rights reserved.