# Combinations and Permutations - 5 digts from 1-9 such that two are prime and two are square, no repeats

A pin code is 5 digits long, using only the numbers 1-9 with no repeats. How many combinations are there if two of the numbers must be prime and two must be square.

The primes are 2, 3, 5 and 7 (so there must be two of these) Squares are 1, 4, and 9 (two of these) The remaining digit must be a 6 or 8

I think the right answer is 8640 What I think I've got so far is 4P2 * 3P2 * 5! = 8640 I'm not sure if that's correct. My thinking was you have 2 out of 4 primes and 2 out of 3 squares. The 5! for the different ordering of 5 digits. But I haven't done anything about the remaining digit (either 6 or 8).

Is anyone able to offer a better explanation of how to work this out.

Thank You

Edit: I realised I haven't clarified whether it is exactly 2 or at least 2 primes (same with squares). I don't have the question with me anymore so I don't remember. My hunch is it said exactly 2 primes and exactly 2 squares.

• $\,^4 C_2 \times \,^3 C_2 \times \,^2 C_1 \times 5! = 4320$ would be more plausible, but it is unclear to me whether $23549$ would satisfy the conditions in the question: if so there would be more – Henry Nov 30 '18 at 10:39
• @Henry I updated the question. I realised I didn't clarify this point. I think 23549 wouldn't count. – NumberCruncher Nov 30 '18 at 10:43

The P means you've already designated a first and a second prime, and a first and a second square. Thus $$5!$$ double-counts a lot of orderings. Use C instead, and this is fine.
And the $$8$$ or $$6$$ you take care of in exactly the same way: you can choose one of them in $$_2C_1$$ ways.
Thus the final answer is $$_4C_2{}\cdot{} _3C_2\cdot{} _2C_1\cdot 5!$$
• @NumberCruncher I get the same digits, but in a different order: $6480$. – Arthur Nov 30 '18 at 11:08