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

computational mathematicsnumber theory

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!

Best Answer

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.

Related Question