Math.pow(base, exponent);
Math.pow(2, 4);
// Outputs 16
// The same as going 2^4, 2 to the power of 4
Math.pow(base, exponent);
Math.pow(2, 4);
// Math.pow()
// The Math. pow() method returns the value of x to the power of y (xy).
// EXAMPLE : 1
let powerOf = Math.pow(2,5);
console.log(powerOf);
// OUTPUT: 32
// EXAMPLE : 2
let powerOf2 = Math.pow(-2,5);
console.log(powerOf2);
// OUTPUT: -32
// EXAMPLE : 3
let powerOf3 = Math.pow();
console.log(powerOf3);
// OUTPUT: NaN
import java.lang.*;
public class MathDemo {
public static void main(String[] args) {
//what is Math.pow(3, 2)?
double x = 3;
double y = 2;
System.out.println("Math.pow(" + x + "," + y + ")=" + Math.pow(x, y));
}
}
//the Output is 9
var x = parseInt(prompt("Enter the base: "))
var y = parseInt(prompt("Enter the power: "))
var value = parseInt(Math.pow(x, y))
console.log(value)
Math.pow(8, 2);