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