Recall that the definition of n! (that is, n factorial) is just 1×2×3×...×n. As she expects to use the day of the week, the day of the month, or the day of the year as the value of n, you must be able to determine the number of occurrences of each decimal digit in numbers as large as 366 factorial (366!), which has 781 digits.
The input data for the program is simply a list of integers for which the digit counts are desired. All of these input values will be less than or equal to 366 and greater than 0, except for the last integer, which will be zero. Don't bother to process this zero value; just stop your program at that point. The output format isn't too critical, but you should make your program produce results that look similar to those shown below.
Madam Phoenix will be forever (or longer) in your debt; she might even give you a trip if you do your job well!
Try the Java solution:
Sample Input
3 8 100 0
3! -- (0) 0 (1) 0 (2) 0 (3) 0 (4) 0 (5) 0 (6) 1 (7) 0 (8) 0 (9) 0 8! -- (0) 2 (1) 0 (2) 1 (3) 1 (4) 1 (5) 0 (6) 0 (7) 0 (8) 0 (9) 0 100! -- (0) 30 (1) 15 (2) 19 (3) 10 (4) 10 (5) 14 (6) 19 (7) 7 (8) 14 (9) 20
1 2 5 10 17 366 0
1! -- (0) 0 (1) 1 (2) 0 (3) 0 (4) 0 (5) 0 (6) 0 (7) 0 (8) 0 (9) 0 2! -- (0) 0 (1) 0 (2) 1 (3) 0 (4) 0 (5) 0 (6) 0 (7) 0 (8) 0 (9) 0 5! -- (0) 1 (1) 1 (2) 1 (3) 0 (4) 0 (5) 0 (6) 0 (7) 0 (8) 0 (9) 0 10! -- (0) 2 (1) 0 (2) 1 (3) 1 (4) 0 (5) 0 (6) 1 (7) 0 (8) 2 (9) 0 17! -- (0) 4 (1) 0 (2) 1 (3) 1 (4) 1 (5) 2 (6) 2 (7) 1 (8) 2 (9) 1 366! -- (0) 160 (1) 93 (2) 58 (3) 60 (4) 74 (5) 81 (6) 58 (7) 64 (8) 59 (9) 74