# HP Forums

Full Version: An interesting challenge
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

How many 9-digit numbers containing all the digits 1,2,3,4,5,6,7,8,9 are prime numbers?

Edited: 19 Nov 2011, 2:39 a.m.

Off the top of my head... Zero.

The sum of 1..9 = 45, which is a multiple of 9. Therefore any 9
digit number formed from a permuation of those 9 digits is also a multiple of 9 and thus not prime.

I guess app calculators are out of competition.

RPL+:

`\<< 123456789 permutate isPrime total \>>`

EDIT: he who doesn't know math, needs a calculator...

Edited: 19 Nov 2011, 7:52 a.m.

Yes, what I had in mind actually was divisibility by 3. What a great way to teach the divisibility by 3 rule, which students can never seem to remember.

Edited: 19 Nov 2011, 7:07 a.m.

Don, do you have an easy proof for this rule (there are two: one for 3 and one for 9 and a similar one for 11)?

You will easily get the idea if you look at the example of a, say, four-digit number.

This number will consist of the four digits abcd. It can be divided by 9 if abcd mod 9 = 0.

A number abcd can be written as

```    1000 a  +  100 b +  10 c  +  d
```
We now want to evaluate
```   (1000 a   +  100 b   +  10 c   +  d) mod 9
=  (999a + a +  99b + b +  9c + c +  d) mod 9
```
Since 999, 99, 9 etc. are all integer multiples of 9, this simplifies to
```   (a  +  b  +  c  +  d) mod 9
```
In other words: in order to test whether a number can be divided by 9, simply check the sum of its digits. So if the remainder of the digit sum divided by 9 is zero, the number itself can be divided by 9 as well. This also means: if the remainder is 3 or 6, i.e. it can be divided by 3, the number itself is divisible by 3.

In other words:

If the digit sum is divisible by 9 resp. 3, so is the number itself.

Example:

```  n = 12345
sum of digits = 15
```
15 is not divisible by 9, but the remainder (6) is. Or: 15 can be divided by 3. So 12345 is divisible by 3 as well.

BTW, you can also continue with the digit sum of 15 which is 6 and judge the divisibility from this result. ;-)

Dieter

Edited: 19 Nov 2011, 8:43 a.m.

Search for 'divisibility' in Wikipedia

Patrice

Well, I don't have a proof, just the fact that every middle school math textbook I've seen that discusses factoring and divisibility lists the test for divisibility for selected numbers. I generally teach the easy ones: 2 (even number), 3 (sum of digits divisible by 3), 5 (ends in 0 or 5), and 10 (ends in 0). There are tests for divisibility for other numbers, as Wikipedia shows, but in middle school we usually limit it to those 4.

4 is easy: the last two digits (read as a two digit number) need to be divisible by 4.

There is another rule for 11: It deals with the pairwise digit sum. Example 121: The pairwise sum is 01 + 21 = 22. This is divisible by 11 and hence 121 is. The proof must be similar to what Dieter has shown.

Quote:
The proof must be similar to what Dieter has shown.

You bet. :-)

The method is based on the fact that 99, 9999, 999999 etc. are all divisible by 11 (which can be easily proven as well). The approach is basically the same as before. Here, the number consists of groups with two digits aa, bb, cc etc., so an eight-digit value can be written as aabbccdd.

```   aabbccdd mod 11
=  (1000000 aa       + 10000 bb      + 100 cc      +  dd) mod 11
=  ( 999999 aa + aa  +  9999 bb + bb +  99 cc + cc +  dd) mod 11
```
Since 99, 9999, 999999 etc. are divisible by 11, this simplifies to
```   (aa + bb + cc + dd) mod 11
```
q.e.d.

Dieter

I'd be stunned if this problem would make the rule easier to remember. It seems like the rule is pretty easy to remember as is.

Actually, it seems like an easier rule to help remember this (as well as the times tables for 9) is that 9 times any single digit number results in a number whose digits not only add to a multiple of 9, but 9 itself.