Answer:
public class Main {
public static void main(String[] args) {
writeNums(5);
System.out.println(); // to complete the line of output
writeNums(12);
System.out.println(); // to complete the line of output
}
public static void writeNums(int n) {
if (n < 1) {
throw new IllegalArgumentException("Input must be greater than or equal to 1");
} else if (n == 1) {
System.out.print("1");
} else {
writeNums(n - 1);
System.out.print(", " + n);
}
}
}
Step-by-step explanation: