from itertools import permutations

numbers = "17"
nums = set()

for i in range(1, len(numbers) + 1):
    for p in permutations(numbers, i):
        nums.add(int("".join(p)))

count = 0

for n in nums:
    if n < 2:
        continue
    is_prime = True
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            is_prime = False
            break
    if is_prime:
        count += 1

print(count)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: