Modulus of a very large number

BigInteger has the divideAndRemainder(…) method, one that returns a BigInteger array, the first item the division result, and the second, the remainder (which is what mod really does in Java). Update Including comment by Mark Dickinson to other answer: There’s a much simpler linear-time algorithm: set acc to 0, then for each digit d in … Read more