java - Find the smallest number have 3 integer roots? -
java - Find the smallest number have 3 integer roots? -
java question
find smallest number x, such x > 1, , square roots , cube root , 5th roots integers??
i tried code in java, no result ?
int = 1; while (true) { i++; if (math.pow(i, 1.0 / 2) % 1 == 0 && math.pow(i, 1.0 / 3) % 1 == 0 && math.pow(i, 1.0 / 5) % 1 == 0) { break; } system.out.println(i); }
your if status not right !
your code should :
public static void main(string [] args){ biginteger = new biginteger("2"); double sqroot, cuberoot, fifthroot; while(true) { sqroot = math.sqrt(i.floatvalue()); cuberoot = math.cbrt(i.floatvalue()); fifthroot = math.pow(i.floatvalue(),1/5.0d); system.out.print("i = "+i); if(math.floor(sqroot)==sqroot && math.floor(cuberoot)==cuberoot && math.floor(fifthroot)==fifthroot){ break; } i= i.add(new biginteger("1")); } system.out.println(i); }
java intellij-idea discrete-mathematics
Comments
Post a Comment