# given number n, see whether n has repeated number def has_repeated(n): str_n = str(n) return len(set(str_n)) != len(str_n) def permutation(n, k): prod = 1 for i in range(k): prod *= (n-i) return prod # calculate number of non-repeated n-digit numbe…