The trick is to calculate: "what strategy X makes all of your choices equivalent if the other 8 players play X?"
Step 1: I assumed that the optimal strategy is a random pick between numbers 1 to 5, as I motivated above. (In hindsight it was perhaps not entirely correct, maybe a strategy with a small chance to pick 6 is
slightly better, but the outcome I got should still be pretty close.)
So every candidate strategy is a list of 5 probabilities p1 .. p5 to pick the number 1 .. 5.
Step 2: I used excel to calculate your expected probability of winning the game with a given number N, given that the other 8 players picked their numbers with p1 .. p5.
As to how:
Step 2A: I listed all of the possible results of players 1 to 8 in an excel sheet. Five columns for the numbers of players that picked 1 to 5. So for example one possible result is 3 | 0 | 3 | 2 | 0. However, I omitted the results where you can never win, for example when exactly 1 other player picked 1. Those results are irrelevant because your number doesn't matter.
Step 2B: I calculated the odds of each result, given the probabilities p1 .. p5.
(This is easier than it may sound, you can use the formula p1^k1 * p2^k2 * p3^k3 * p4^k4 * p5^k5 * 8! / (k1! * k2! * k3! * k4! * k5!), where k1 .. k5 are the numbers of other players playing 1 to 5)
Step 2C: For each number that you pick, I checked for which results it is winning and added up the probabilities.
Step 3: now play with the probabilities p1 .. p5 until the expected probability of winning is about equal for each number you can play
link to sheet