I'm quite stuck on this piece of code, the assignment is simple: "given a number n or value, print on the console the sequence from n to 1 and from 1 to n (repeating the number 1 so it should be like this '5432112345').
The recursion per se is not a problem, the real problem is the second part due to the fact that i cannot use any other variable only n. I cannot store the starting value nowhere, since each time i call the method it would be actualized.
Here is the code so far:
public int mirrorRecursive(Integer value){
if (value < 1){ //in case the given value is less than 1 it won't print anything
return value;
}
if(value == 1){ //in case the value is 1, it will be printed and stop the calling
System.out.print(value);
}else{ //in case the value is not 1 or less, it will print and call again the method
System.out.print(value);
mirrorRecursive(--value);
}
return value;
}