| 1 | import java.util.Scanner; |
| 2 | |
| 3 | public class Main { |
| 4 | static void printDecreasing(int n){ // 5 4 3 2 1 |
| 5 | //base case |
| 6 | if(n == 1){ |
| 7 | System.out.println(1); |
| 8 | return; |
| 9 | } |
| 10 | |
| 11 | // self work |
| 12 | System.out.println(n); // n |
| 13 | |
| 14 | // recursive work |
| 15 | printDecreasing(n-1); // n-1, n-2,.....1 |
| 16 | |
| 17 | } |
| 18 | |
| 19 | static void printIncreasing(int n){ // 1, 2, ..... n-1, n |
| 20 | //base case |
| 21 | if(n == 1){ |
| 22 | System.out.println(n); |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | //recursive work |
| 27 | printIncreasing(n-1); // 1, 2, .... n-1 |
| 28 | |
| 29 | //self work |
| 30 | System.out.println(n); |
| 31 | } |
| 32 | |
| 33 | public static void main(String[] args) { |
| 34 | Scanner sc = new Scanner(System.in); |
| 35 | int n = sc.nextInt(); |
| 36 | // printIncreasing(n); |
| 37 | printDecreasing(n); |
| 38 | } |
| 39 | } |
nothing calls this directly
no outgoing calls
no test coverage detected