+ 3

Square root

for example you can write sqrt(9 )= 3 but how can I write (8)=2 Actually u got the point lol. I don't know how it is called in English. cube root?? hexagon root?? anyway how can I code in JAVA

2nd Apr 2018, 9:59 PM
TimeTraveler
TimeTraveler - avatar
4 ответов
+ 11
for that U can use Math.pow(a,b) funcn directly //availble in java 👉Math.pow(a,2); //a^2 ... square 👉Math.pow (a,1.0/3.0); //a^(1/3) ... cuberoot 👉Math.pow (a,1.0/2.0) //a^1/2 ... square root of a //can also be written as Math.sqrt(a); //in above example ... it will be 👉👉 int b=(int)Math.pow(8,1.0/3.0); //remember value comes out as double ... so we neex to typecast it to int type
3rd Apr 2018, 4:15 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
It's known as cube root: https://www.tutorialspoint.com/java/lang/math_cbrt.htm "The java.lang.Math.cbrt(double a) returns the cube root of a double value"
2nd Apr 2018, 10:07 PM
Emma
+ 2
for each type of root there is a certain word right??
2nd Apr 2018, 10:13 PM
TimeTraveler
TimeTraveler - avatar
+ 2
In English, we say square root for n^(1/2) and cube root for n^(1/3). n^(1/4) is known as quad root or fourth root. All other roots are known as fifth, sixth, seventh, eighth root etc.
2nd Apr 2018, 10:31 PM
Emma