From 9c55572cf6ab1c535eb99fb285e564e06e4eb5b1 Mon Sep 17 00:00:00 2001 From: Muhammad Muneeb Mubashar Date: Thu, 12 Feb 2026 04:56:38 -0800 Subject: [PATCH] Refactor pow method to use Math.pow --- src/main/java/com/thealgorithms/maths/Pow.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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; } }