title: how to do arithmetic on objects
body: <p>I have a few <code>BigInteger</code> objects in a two simple java files. But, since they aren't primitive types, the arithmetic operators won't work on them.</p>
  
  <p>There is an error every time an operator is used, like so:</p>
  
  <pre><code>.\_Mathematics\Formulas\Factorial.java:10: error: bad operand types for binary o
  perator '*'
                          result *= i;
                                 ^
    first type:  BigInteger
    second type: int
  </code></pre>
  
  <p>Here they are:</p>
  
  <pre><code>package _Mathematics.Formulas;
  import java.math.*;
  
  public class Factorial&lt;T extends Number&gt; {
      public T o;
      public BigInteger r;
      public Factorial(int num) {
          BigInteger result = new BigInteger("1");
          for(int i = num; i &gt; 0; i--)
              result *= i;
          this.o = num;
          this.r = result;
      }
  } 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>package _Mathematics.Formulas;
  import java.math.*;
  
  public class Power&lt;T extends Number&gt; {
      public T o;
      public BigInteger r;
      public Power(T num, int pow) {
          BigInteger result = new BigInteger(1);
          for(int i = 0; i &lt; pow; i++) {
              result *= num;
          }
          this.o = num;
          this.r = result;
      }
  }
  </code></pre>
  
  <p>I looked around for a while for how to fix this, but I couldn't find an answer.</p>
  
  <p>Can somebody help me with this?</p>
  
  <p>Thanks.</p>