Given two postive integers **L** and **R**, the task is to print the numbers in the range **[L, R]** which have their digits in strictly increasing order.**Examples:**

Input:L = 10, R = 15Output:12 13 14 15Explanation:

In the range [10, 15], only the numbers {12, 13, 14, 15} have their digits in strictly increasing order.Input:L = 60, R = 70Output:67 68 69Explanation:

In the range [60, 70], only the numbers {67, 68, 69} have their digits in strictly increasing order.

**Approach:** The idea is to iterate over the range **[L, R]** and for each number in this range check if digits of this number are in strictly increasing order or not. If yes then print that number else check for the next number.

Below is the implementation of the above approach:

## C++

`// C++ program for the above approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to print all numbers ` `// in the range [L, R] having digits ` `// in strictly increasing order ` `void` `printNum(` `int` `L, ` `int` `R) ` `{ ` ` ` `// Iterate over the range ` ` ` `for` `(` `int` `i = L; i <= R; i++) { ` ` ` ` ` `int` `temp = i; ` ` ` `int` `c = 10; ` ` ` `int` `flag = 0; ` ` ` ` ` `// Iterate over the digits ` ` ` `while` `(temp > 0) { ` ` ` ` ` `// Check if the current digit ` ` ` `// is >= the previous digit ` ` ` `if` `(temp % 10 >= c) { ` ` ` ` ` `flag = 1; ` ` ` `break` `; ` ` ` `} ` ` ` ` ` `c = temp % 10; ` ` ` `temp /= 10; ` ` ` `} ` ` ` ` ` `// If the digits are in ` ` ` `// ascending order ` ` ` `if` `(flag == 0) ` ` ` `cout << i << ` `" "` `; ` ` ` `} ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` `// Given range L and R ` ` ` `int` `L = 10, R = 15; ` ` ` `// Function Call ` ` ` `printNum(L, R); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program for the above approach ` `import` `java.util.*; ` ` ` `class` `GFG{ ` ` ` `// Function to print all numbers ` `// in the range [L, R] having digits ` `// in strictly increasing order ` `static` `void` `printNum(` `int` `L, ` `int` `R) ` `{ ` ` ` ` ` `// Iterate over the range ` ` ` `for` `(` `int` `i = L; i <= R; i++) ` ` ` `{ ` ` ` `int` `temp = i; ` ` ` `int` `c = ` `10` `; ` ` ` `int` `flag = ` `0` `; ` ` ` ` ` `// Iterate over the digits ` ` ` `while` `(temp > ` `0` `) ` ` ` `{ ` ` ` ` ` `// Check if the current digit ` ` ` `// is >= the previous digit ` ` ` `if` `(temp % ` `10` `>= c) ` ` ` `{ ` ` ` `flag = ` `1` `; ` ` ` `break` `; ` ` ` `} ` ` ` ` ` `c = temp % ` `10` `; ` ` ` `temp /= ` `10` `; ` ` ` `} ` ` ` ` ` `// If the digits are in ` ` ` `// ascending order ` ` ` `if` `(flag == ` `0` `) ` ` ` `System.out.print(i + ` `" "` `); ` ` ` `} ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` ` ` `// Given range L and R ` ` ` `int` `L = ` `10` `, R = ` `15` `; ` ` ` ` ` `// Function call ` ` ` `printNum(L, R); ` `} ` `} ` ` ` `// This code is contributed by offbeat ` |

*chevron_right*

*filter_none*

## C#

`// C# program for the above approach ` `using` `System; ` ` ` `class` `GFG{ ` ` ` `// Function to print all numbers ` `// in the range [L, R] having digits ` `// in strictly increasing order ` `static` `void` `printNum(` `int` `L, ` `int` `R) ` `{ ` ` ` ` ` `// Iterate over the range ` ` ` `for` `(` `int` `i = L; i <= R; i++) ` ` ` `{ ` ` ` `int` `temp = i; ` ` ` `int` `c = 10; ` ` ` `int` `flag = 0; ` ` ` ` ` `// Iterate over the digits ` ` ` `while` `(temp > 0) ` ` ` `{ ` ` ` ` ` `// Check if the current digit ` ` ` `// is >= the previous digit ` ` ` `if` `(temp % 10 >= c) ` ` ` `{ ` ` ` `flag = 1; ` ` ` `break` `; ` ` ` `} ` ` ` ` ` `c = temp % 10; ` ` ` `temp /= 10; ` ` ` `} ` ` ` ` ` `// If the digits are in ` ` ` `// ascending order ` ` ` `if` `(flag == 0) ` ` ` `Console.Write(i + ` `" "` `); ` ` ` `} ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` ` ` `// Given range L and R ` ` ` `int` `L = 10, R = 15; ` ` ` ` ` `// Function call ` ` ` `printNum(L, R); ` `} ` `} ` ` ` `// This code is contributed by jrishabh99 ` |

*chevron_right*

*filter_none*

**Output:**

12 13 14 15

**Time Complexity** O(N), N is absolute difference between L and R. **Auxillary Space:** O(1)

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Generate k digit numbers with digits in strictly increasing order
- Print array elements in alternatively increasing and decreasing order
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Sort only non-prime numbers of an array in increasing order
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Print a number strictly less than a given number such that all its digits are distinct.
- Count of numbers whose sum of increasing powers of digits is equal to the number itself
- Print number in ascending order which contains 1, 2 and 3 in their digits.
- Print all increasing sequences of length k from first n natural numbers
- Count of numbers with all digits same in a given range
- Count of numbers from range [L, R] that end with any of the given digits
- Count of numbers from range [L, R] whose sum of digits is Y
- Count of Numbers in Range where the number does not contain more than K non zero digits
- Total numbers with no repeated digits in a range
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3
- Count numbers in range L-R that are divisible by all of its non-zero digits
- Cumulative product of digits of all numbers in the given range
- Check if it is possible to make two martices strictly increasing by swapping corresponding values only
- Split the array elements into strictly increasing and decreasing sequence
- Print numbers with digits 0 and 1 only such that their sum is N

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.