I had a lot of time to convert this function into a loop, but I cannot find a way to do this. I started with while(m != 0), and then with conventions inside, but the third, if it is one that will not allow me to do this.
public static int calculatePayment(int n, int m){
if(m == 0) return n + 1;
if(n == 0 && m > 0) return calculatePayment(1, m - 1);
if(n > 0 && m > 0) return calculatePayment(calculatePayment(n - 1, m), m - 1);
return 0;
}
In addition, I do not know that I need to use BigInteger, istrograde and inverts that the program will start StackOverFlow Errorand will not let me know if I need it.
Editing:
the first:
m cannot be less than zero in the input, which will never happen. In the same situation with n, the code does not need this.
So far I have this:
while(m > 0){
if(n == 0 && m > 0){n = 1; m--;}
if(n > 0 && m > 0){m--; n = IDONTKNOWWHAT;}
}
if(m == 0) return n + 1;
Also, the code cannot be reduced to a mathematical formula, I tried.
source
share