style: enable ParameterName in CheckStyle. (#5196)

* Enabled: ParameterName in CheckStyle.

* Refactored to fix  bug caused by selfAssignment of variables in VectorCrossproduct class
This commit is contained in:
Godwill Christopher
2024-05-31 14:01:11 -06:00
committed by GitHub
parent 2568b96784
commit c42b1c940c
23 changed files with 139 additions and 139 deletions

View File

@ -11,30 +11,30 @@ public class PowerSum {
private int count = 0;
private int sum = 0;
public int powSum(int N, int X) {
sum(N, X, 1);
public int powSum(int n, int x) {
sum(n, x, 1);
return count;
}
// here i is the natural number which will be raised by X and added in sum.
public void sum(int N, int X, int i) {
public void sum(int n, int x, int i) {
// if sum is equal to N that is one of our answer and count is increased.
if (sum == N) {
if (sum == n) {
count++;
return;
} // we will be adding next natural number raised to X only if on adding it in sum the
// result is less than N.
else if (sum + power(i, X) <= N) {
sum += power(i, X);
sum(N, X, i + 1);
else if (sum + power(i, x) <= n) {
sum += power(i, x);
sum(n, x, i + 1);
// backtracking and removing the number added last since no possible combination is
// there with it.
sum -= power(i, X);
sum -= power(i, x);
}
if (power(i, X) < N) {
if (power(i, x) < n) {
// calling the sum function with next natural number after backtracking if when it is
// raised to X is still less than X.
sum(N, X, i + 1);
sum(n, x, i + 1);
}
}