title: How to keep increasing the value of a BigInteger?
body: <p>I have a series of BigInteger problems that require the use of constantly increasing a BigInteger.  I proposed a loop, but that is extremely tricky due to the fact that BigIntegers and BigDecimals are immutable.</p>
  
  <p>Here is an example of one of the programs I am trying to make.  It is a method trying to find BigIntegers larger than Long.MAX_VALUE that are divisible by 2 or 3.</p>
  
  <pre><code>    public void divisibleBy2Or3() {
      BigInteger min = new BigInteger("9223372036854775808");
      int j = 0;
      BigInteger increment = new BigInteger("1");
      BigInteger divideBy2 = new BigInteger("2");
      BigInteger divideBy3 = new BigInteger("3");
      while (j &lt; 10) {
          BigInteger a = min.add(increment);
          BigInteger b = a.divide(divideBy2); BigInteger c = a.divide(divideBy3);
          if (b.multiply(divideBy2) == a || c.multiply(divideBy3) == a) {
              System.out.print(a + " ");
              j++;
          }
      }
  }
  </code></pre>
  
  <p>The problem with this code is I can't seem to figure out how to get the BigInteger that I am testing for each iteration of the loop to add itself with each iteration.  I'm also a little unsure as to if the multiply methods actually work for this scenario, as whenever I run the program, it hangs and shows a blank console</p>