A $1 \times n$ rectangle ($n \geq 1 $) is divided into $n$ unit ($1 \times 1$) squares. Each square of this rectangle is colored red, blue or green. Let $f(n)$ be the number of colourings of the rectangle in which there are an even number of red squares. What is the largest prime factor of $f(9)/f(3)$? (The number of red squares can be zero.)
1. **Define the problem and generating function:**
   We need to find the number of ways to color a $1 \times n$ rectangle with red, blue, and green such that there are an even number of red squares. The generating function for a $1 \times n$ rectangle is given by:
   \[
   P(r, g, b) = (r + g + b)^n
   \]
   Here, $r$, $g$, and $b$ represent the colors red, green, and blue respectively.

2. **Simplify the generating function:**
   To find the number of colorings with an even number of red squares, we consider the generating function:
   \[
   P(r, 1, 1) = (r + 2)^n
   \]
   This is because we replace $g$ and $b$ with 1, as we are not concerned with the specific counts of green and blue squares.

3. **Use the Roots of Unity Filter:**
   To isolate the terms where the exponent of $r$ is even, we use the Roots of Unity Filter. This technique helps in summing the coefficients of $r^k$ where $k$ is even:
   \[
   \frac{P(1, 1, 1) + P(-1, 1, 1)}{2} = \frac{(1 + 2)^n + (-1 + 2)^n}{2} = \frac{3^n + 1}{2}
   \]
   Therefore, the number of colorings with an even number of red squares is:
   \[
   f(n) = \frac{3^n + 1}{2}
   \]

4. **Calculate \( f(9) \) and \( f(3) \):**
   \[
   f(9) = \frac{3^9 + 1}{2} = \frac{19683 + 1}{2} = \frac{19684}{2} = 9842
   \]
   \[
   f(3) = \frac{3^3 + 1}{2} = \frac{27 + 1}{2} = \frac{28}{2} = 14
   \]

5. **Find the ratio \( \frac{f(9)}{f(3)} \):**
   \[
   \frac{f(9)}{f(3)} = \frac{9842}{14} = 703
   \]

6. **Determine the largest prime factor of 703:**
   Factorize 703:
   \[
   703 = 19 \times 37
   \]
   The prime factors of 703 are 19 and 37. The largest prime factor is 37.

The final answer is $\boxed{37}$