
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Program to count n digit integers where digits are strictly increasing in Python
Suppose we have a number n, we have to find the number of n-digit positive integers such that the digits are in strictly increasing order.
So, if the input is like n = 3, then the output will be 84, as numbers are 123, 124, 125, ..., 678,789
To solve this, we will follow these steps −
if n < 9 is non-zero, then
return Combination (9Cn)
otherwise,
return 0
Let us see the following implementation to get better understanding −
Example
from math import factorial as f class Solution: def solve(self, n): if n < 9: return f(9) / f(n) / f(9 - n) else: return 0 ob = Solution() print(ob.solve(3))
Input
3
Output
84
- Related Articles
- Print all n-digit strictly increasing numbers in C++
- Count Strictly Increasing Subarrays in C++
- Program to check whether list is strictly increasing or strictly decreasing in Python
- Program to find number of strictly increasing colorful candle sequences are there in Python
- Program to find length of contiguous strictly increasing sublist in Python
- Program to find nearest number of n where all digits are odd in python
- Count of m digit integers that are divisible by an integer n in C++
- A strictly increasing linked list in Python
- Program to find length of longest strictly increasing then decreasing sublist in Python
- Program to find number not greater than n where all digits are non-decreasing in python
- Program to count number of stepping numbers of n digits in python
- Check if list is strictly increasing in Python
- Program to find length of longest contiguously strictly increasing sublist after removal in Python
- Count positive integers with 0 as a digit and maximum ‘d' digits in C++
- Program to find minimum number of operations required to make lists strictly Increasing in python

Advertisements