So I have an infinite loop on my hands, and I was wondering if anyone can help me out. My purpose is to make an iterative cube root function using newtons method. Any help would be greatly appreciated.

I set a = 1.0 just to test. I need to go through numbers 1 -50 but thats really irrelavant.

Code :

public static void cRoot () { ///newtons method for compution. boolean closeEnough = false; double X, XX; double a = 1.0; /// set the cubeRoot for 0 and 1. if (a == 0.0) X = 0.0; if (a == 1.0) X = 1.0; X = a/2.0; // first guess. while( closeEnough == false ) { // Next guess XX = (1/3.0 *( 2.0 * Math.pow(X, 3) + a) / (Math.pow(X, 2))); // Is it close enough? if ( (XX - X)/X < 0.00001) // New guestimate. X = XX; } /// Output of the cuberoot. System.out.print(X); } }