/* Problem Description : You are given an integer A, print A to 1 using using recursion.
Note :- After printing all the numbers from A to 1, print a new line.
Problem Constraints : 1 <= A <= 10^4 */
import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public void printdecreasing(int A) {
//BASE Condition
if (A == 0) {
System.out.println(); // Print a new line.
return;
}
System.out.print(A + " ");
printdecreasing(A - 1); // Call itself recursively
}
public static void main(String[] args) {
int n = 10;
Main main = new Main();
main.printdecreasing(n); // Call the method to print decreasing numbers
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: