Given two numbers, let\'s say start = 1 and end = 4, I am trying to count all the numbers in sequence up and then down . No looping is allowed
start = 1
end = 4
try this
private static int CountUpAndDown(int end, int first, int start) { if(end==first) { return -1; } if (start > end) { System.out.println(--end); } else { System.out.println(start++); } return CountUpAndDown(end, first, start); }