Skip to content

Commit f16689e

Browse files
authored
updated PowerSum
1 parent d6f0e1e commit f16689e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/com/thealgorithms/backtracking/PowerSum.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public class PowerSum {
1515
/**
1616
* Calculates the number of ways to express the target sum as a sum of Xth powers of unique natural numbers.
1717
*
18-
* @param targetSum The target sum to achieve (N in the problem statement)
19-
* @param power The power to raise natural numbers to (X in the problem statement)
20-
* @return The number of ways to express the target sum
18+
* targetSum The target sum to achieve (N in the problem statement)
19+
* power The power to raise natural numbers to (X in the problem statement)
20+
* The number of ways to express the target sum
2121
*/
2222
public int powSum(int targetSum, int power) {
2323
return sumRecursive(targetSum, power, 1, 0);
@@ -26,11 +26,11 @@ public int powSum(int targetSum, int power) {
2626
/**
2727
* Recursively calculates the number of ways to express the remaining sum as a sum of Xth powers.
2828
*
29-
* @param remainingSum The remaining sum to achieve
30-
* @param power The power to raise natural numbers to (X in the problem statement)
31-
* @param currentNumber The current natural number being considered
32-
* @param currentSum The current sum of powered numbers
33-
* @return The number of valid combinations
29+
* remainingSum The remaining sum to achieve
30+
* power The power to raise natural numbers to (X in the problem statement)
31+
* currentNumber The current natural number being considered
32+
* currentSum The current sum of powered numbers
33+
* The number of valid combinations
3434
*/
3535
private int sumRecursive(int remainingSum, int power, int currentNumber, int currentSum) {
3636
int newSum = currentSum + (int) Math.pow(currentNumber, power);

0 commit comments

Comments
 (0)