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.

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!
$$
