Respuesta :
Answer:
The Codes and Screenshot to answer the question above are both given below:(the Screenshot is attached to offer you an additional readability of code)
note: File Name must be the same as our class name ( which is Increasing.java in our case.)
Explanation:
Code is given below:
/* File Name Should be Increasing.java
* Java program to print all n-digit numbers whose digits
* are strictly increasing from left to right
*/
import java.util.Scanner;
class Increasing
{
// Function to print all n-digit numbers whose digits
// are strictly increasing from left to right.
// out --> Stores current output number as string
// start --> Current starting digit to be considered
public static void findStrictlyIncreasingNum(int start, String out, int n)
{
// If number becomes N-digit, print it
if (n == 0)
{
System.out.print(out + " ");
return;
}
// Recall function 9 time with (n-1) digits
for (int i = start; i <= 9; i++)
{
// append current digit to number
String str = out + Integer.toString(i);
// recurse for next digit
findStrictlyIncreasingNum(i + 1, str, n - 1);
}
}
// Driver code for above function
public static void main(String args[])
{ //User Input
Scanner sc = new Scanner( System.in);
System.out.println("Enter a number:");
int n = sc.nextInt();
//Function to calcuclate and print strictly Increasing series
findStrictlyIncreasingNum(0, " ", n);
}
}
//End of Code


