In: Computer Science
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal to n, such that the digit to the right is greater than the left digit (ai+1 > ai). E.g. if n=3 (123,124,125,……129,234,…..789)
from itertools import permutations
A=[]
N=int(input("Enter number of digits: "))
Poss_com = permutations([1,2,3,4,5,6,7,8,9], N) #this function gives possible combinations of N Digits Numbers Out digits in list(Non-repetitive) This is non reoetitive but condition in your question is satisfied with this.
for i in Poss_com:
if i[0]<i[1] and i[1]<i[2]:
print(i[0],i[1],i[2])
Outputs