# Permutation of a number constructed only with odd digits has at least one prime?

Given a number $$N$$ with some properties:

• It is only constructed using these digits: $$\{1,3,5,7,9\}$$ (e.g. $$135$$ , $$7713$$. NOT: $$1231$$ which includes the digit $$2$$)
• It has at least $$3$$ distinct odd digits. (for example these are not allowed: $$7755$$, $$13$$, $$11$$, $$3$$ etc..)
• Its sum is not divisible by $$3$$ (and thus $$3 \nmid N$$)

I've written a (very clunky) Python program that takes a random number with these very properties, and checked:

If the number is divisible by $$3$$ - skip
Else - check each permutation of the number if it is a prime.

For example (for simplicity I've used $$5131$$ which has only $$2$$ unique odd digits):

$$335511$$ - skip, it is divisible by $$3$$.
$$5131$$ - check each permutation of this number if it is a prime:
$$5131$$ - not a prime. $$5113$$ - not a prime. etc... until we hit a prime: $$5113$$

The results were quite nice, I've noticed that if the numbers meet those constraints then:

• At least one permutation of $$N$$ is a prime

These constraints look very 'harsh' at the beginning, but I don't think it is that trivial - that a number with $$3$$ or more unique odd digits has at least one permutation that is a prime (If it is not divisible by $$3$$).

Is there any reason why these numbers behave this way?

## UPDATE

Now assume $$N$$ can be constructed only using $$\{1,3,7,9\}$$ (no $$5$$ allowed) and it has at least $$3$$ unique digits (so maybe it contains $$1,3,7$$ or $$1,3,7,9$$ or $$3,7,9$$ etc..)

Now the number is either divisible by $$3$$ or has at least one prime permutation.
I could not seem to find any counter-example to this, however it must exist as what @lulu said, it is a matter of probability, but after checking millions and million of numbers - I couldn't ... so such number does exist?

Thank you!

• There are a lot of prime numbers. Just for example, if you stick with $8$ digits or fewer then there are $\pi(10^8)\approx 5.7\times 10^6$ primes. It follows that if you choose a random odd number with $8$ digits there's a greater than $\frac 19$ chance that it is prime. Since it is likely that your number has many more than $9$ permutations, this may just be chance.
– lulu
Jul 16 '20 at 10:51
• To build counterexamples, I'd take a long number with all but two digits equal to $5$ and then two other odd digits. That keeps the number of relevant permutations as low as possible (roughly $2L$ where $L$ is the length).
– lulu
Jul 16 '20 at 11:27
• @lulu Hey thank you for answering! please see my update question it has more constraints Jul 16 '20 at 18:04
• Just as a sidelight, you may want to investigate the topic of permutation primes: those primes for which every permutation of their digits produces a prime, e.g. 991, the largest such with three digits. There is a Wiki page on them if you are interested. Jul 16 '20 at 18:13
• @ChrisLeary Thanks for the answer! but I am talking about at least one* prime permutation, not all Jul 16 '20 at 18:17

No permutation of the digits $$1,5,5,5,7$$ creates a prime. Obviously it cannot end in a $$5$$, and the others are:

$$15557=47\times331$$
$$51557=11\times43\times109$$
$$55157=19\times2903$$
$$55517=7\times7\times11\times103$$
$$55571=61\times911$$
$$55751=197\times283$$
$$57551=13\times19\times233$$
$$75551=7\times43\times251$$

For 10 digits there is also $$3555555557$$ and $$5555555579$$.

I found these by computer. There are no other such combinations with 12 digits or fewer.

• Nice catch! I've actually looked it up beforehand (not the same number but other number with 5 in it) and it seems that this what causes the problem, what about a number that is constructed from $\{1,3,7,9\}$ ? Jul 16 '20 at 10:51
• @Remember1312 As lulu points out in their comment, the probability is pretty low. It is also not surprising that in the ones I found, all but two of the digits are $5$, because then there are only $2n-2$ numbers that would have to be composite. WIthout a $5$, the number of permutations that would have to be composite is so much bigger that it is very very unlikely to happen, though not necessarily impossible, and I think with more digits it gets ever more unlikely. Jul 16 '20 at 11:21
• Thank you sir! Please see my update, I am very curious to look for your answers, thank you again Jul 16 '20 at 18:05