+ 1

How to find square roots in Java?

I am trying to make a prime number generator and I want it efficient. What is the function and are there any tips to make it even more efficient?

4th Apr 2018, 9:39 PM
Ethan
Ethan - avatar
2 odpowiedzi
+ 4
Math.sqrt(your_variable)... It returns a double... Here is the Math class docs... You can see all its methods and more https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html
4th Apr 2018, 9:41 PM
cyk
cyk - avatar
+ 1
Import the sqrt function from the math class... import java.lang.Math; Math.sqrt(double number);
4th Apr 2018, 9:42 PM
TurtleShell
TurtleShell - avatar