Answers for "Write a method that raises a number to a power without using Math.pow() method"

0

Write a method that raises a number to a power without using Math.pow() method

public class Power {

    public static void main(String[] args) {

        int base = 3, exponent = 4;

        long result = 1;

        while (exponent != 0)
        {
            result *= base;
            --exponent;
        }

        System.out.println("Answer = " + result);
    }
}
Posted by: Guest on June-04-2020

Code answers related to "Write a method that raises a number to a power without using Math.pow() method"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language