Infinite loop code
<p>I'm trying to code an Integrate class which will give me the integral of a function using the Trapezoidal rule. For some reason, the code I have never resolves to a value and stays stuck in the "sum +=" step:</p>

<pre><code>public static double Trap(int exponent, int a, int b, int n) {
    double h = (double) (b-a)/n;

    double sum = 0;
    for(int i = a; i &lt;= b; i+=h)
        sum += (Math.pow(i, exponent) + Math.pow(i+1, exponent))/2; //trouble!

    return h * sum;
}

public static void main(String[] args) {
    System.out.println(Trap(3,1,3,10)); //integral of x^3 from 1 to 3, 
    divided into 10 parts
}
</code></pre>
