Python Compiler
import math combination = int(input("Enter the number of Combination: ")) num = [[0]*50 for _ in range(50)] for i in range(0, combination): num[i] = int(input("Enter (int) Digit %d: " % (i+1))) limit = int(input("Enter the limit: ")) #iterate from 1 to limit for i in range(1, limit+1): copyNum = i count = 0 flag = 0 #check each digit starting from last digit while(copyNum != 0): count += 1 lastDigit = copyNum % 10 for j in range(0, combination): if(num[j] == lastDigit): flag += 1 copyNum = math.floor(copyNum / 10) if(count == flag): print(i, end=" ")
OUTPUT
Enter the number of Combination: 2
Enter (int) Digit 1: 6
Enter (int) Digit 2: 9
Enter the Limit: 500
6 9 66 69 96 99
×

Save as Private