Skip to content

Commit

Permalink
PowerSum
Browse files Browse the repository at this point in the history
  • Loading branch information
Atousa committed Sep 24, 2021
1 parent 93b68dd commit 6fc5449
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions Recursion/PowerSum.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,6 @@ public static void powerSumHelper2(int X, int K, int curNum, int curSum) {



public static void powerSum1(int X, int K) {

powerSumHelper1(X, K, 1,0);
}

private static void powerSumHelper1(int X, int K,int curNum, int curSum) {
if(curSum == X) {
numWay+=1;
return;
}
if(curNum == X/K || curSum > X)
return;
powerSumHelper1(X, K, curNum+1, curSum);

int times = 1;
for(int i = 0; i < K; i++) {
times*=curNum;
}
powerSumHelper1(X,K, curNum+1, curSum + times);
}

public static void main(String[] args) {
//powerSum1(100,2);
//System.out.println(numWay);
Expand Down

0 comments on commit 6fc5449

Please sign in to comment.