diff --git a/src/main/java/com/thealgorithms/maths/Pow.java b/src/main/java/com/thealgorithms/maths/Pow.java index 377b37ac4569..2ca112670f09 100644 --- a/src/main/java/com/thealgorithms/maths/Pow.java +++ b/src/main/java/com/thealgorithms/maths/Pow.java @@ -27,10 +27,7 @@ public static long pow(int a, int b) { if (b < 0) { throw new IllegalArgumentException("Exponent must be non-negative."); } - long result = 1; - for (int i = 1; i <= b; i++) { - result *= a; - } + long result = (long) Math.pow(a , b); return result; } }