# Listing numbers with non-repeating digits

I tried to search this but could not find. Given a number of digits(the maximum being 0 to 9), how can I generate a list of all possible numbers without repeating the digits in each number? e.g. Given the digits 1,2 & 3 I should get 123, 132, 213. 231, 312, & 321. I want to generate such a list of digits with all digits from 0 to 9. Thanks. I am relatively new at Mathematica and am trying to learn.

The lists of digits of the numbers you are looking for are mere permutations of the digits $0,\,1,\,2\,\dotsc,9$. Permutations can provide you with these permutations; FromDigits turns them into numbers.

FromDigits /@ Permutations[Range[0,9]]


This simply ignores leading 0-digits. If you want only numbers with 10 true digits, you can use the following:

FromDigits /@ Drop[Permutations[Range[0, 9]], 9!]

• 0 can't be the first digit. Commented Jul 13, 2018 at 6:46
• Leading 0 digits are removed automatically. Commented Jul 13, 2018 at 6:58
• Or this Drop[FromDigits /@ Permutations[Range[0, 3]], 9!] Commented Jul 14, 2018 at 4:55
• @OkkesDulgerci Very good point. It's much faster. Thanks. Commented Jul 15, 2018 at 14:32