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*

## Python3

`# Python3 program for the above approach ` ` ` `# Function to print all numbers in ` `# the range [L, R] having digits ` `# in strictly increasing order ` `def` `printNum(L, R): ` ` ` ` ` `# Iterate over the range ` ` ` `for` `i ` `in` `range` `(L, R ` `+` `1` `): ` ` ` `temp ` `=` `i ` ` ` `c ` `=` `10` ` ` `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` `): ` ` ` `print` `(i, end ` `=` `" "` `) ` ` ` `# Driver Code ` ` ` `# Given range L and R ` `L ` `=` `10` `R ` `=` `15` ` ` `# Function call ` `printNum(L, R) ` ` ` `# This code is contributed by code_hunt` |

*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. **Auxiliary 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 a number strictly less than a given number such that all its digits are distinct.
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Sort all even numbers in ascending order and then sort all odd numbers in descending order
- Split the array elements into strictly increasing and decreasing sequence
- Check if it is possible to make two martices strictly increasing by swapping corresponding values only
- Check whether an array can be made strictly increasing by modifying atmost one element
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Minimum digits to be removed to make either all digits or alternating digits same
- Length of largest sub-array having primes strictly greater than non-primes
- Longest Subarray having strictly positive XOR
- Count numbers formed by given two digit with sum having given digits
- Print array elements in alternatively increasing and decreasing order
- Print all increasing sequences of length k from first n natural numbers
- Count of numbers with all digits same in a given range
- Cumulative product of digits of all numbers in the given range
- Count all prime numbers in a given range whose sum of digits is also prime
- Generate all N digit numbers having absolute difference as K between adjacent digits

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.