3! = 6

(0) 0 (1) 0 (2) 0 (3) 0 (4) 0

(5) 0 (6) 1 (7) 0 (8) 0 (9) 0

8! = 40320

(0) 2 (1) 0 (2) 1 (3) 1 (4) 1

(5) 0 (6) 0 (7) 0 (8) 0 (9) 0

An obvious way of doing it is to find the factorial and then keep on dividing the number by 10 to get the digits and increment corresponding counters.

Something like:

Expand|Select|Wrap|Line Numbers

- while(factorial)
- {
- Counters[factorial%10]++;
- factorial /= 10;
- }