/* Problem Description : You are given an integer A, print 1 to A using using recursion.
Note :- After printing all the numbers from 1 to A, print a new line.
Problem Constraints : 1 <= A <= 104 */
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
// Function to print numbers from 1 to A using recursion
public static void printNumbers(int A) {
if (A == 0) {
return;
}
printNumbers(A - 1); // Recursively print numbers from A-1 to 1
System.out.print(A + " "); // Print the current number followed by a space
}
public static void main(String[] args) {
int A = 10; // Change the input value here
printNumbers(A);
System.out.println(); // Add a newline after all numbers are printed
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: