Expected value of the expression $3 □ 3 □ 3 □ ⋯ □ 3 □ 3$ Let $p = 2017$ be a prime number. Let $E$ be the expected value of the expression
$3
□
3
□
3
□
⋯
□
3
□
3$
where there are
$p
+
3$
threes and
$p
+
2$
boxes, and one of the four arithmetic operations
{
+
,
−
,
×
,
÷
}
is uniformly chosen at random to replace each of the boxes. If
$E
=
\frac{m}{n}$
, where
$m$
and
$n$
are relatively prime positive integers, find the remainder when
$m
+
n$
is divided by
$p$
.
It's a question from https://gonitzoggo.com/archive/problem/431/english
Recently, I've been taking preparation for junior Math Olympiad Contest and found this problem.
I've tried many combinations of arithmetic operations to find the value of $E $  but ended up each time getting a new value which doesn't match with the answer. How can I get the exact value of $E$ ?
 A: Partial answer
It may be easier to start with smaller versions of the problem, and see if we can find a pattern.
When there is only one operator box, with two operands, there are four possible expression values:

*

*$3 + 3 = 6$

*$3 - 3 = 0$

*$3 \times 3 = 9$

*$3 \div 3 = 1$
So $E = 4$.
With more operators, let's get help from our computer.
from fractions import *

# Use Fraction arithmetic to avoid floating-point errors.
F3 = Fraction(3)

OPERATORS = ['+', '-', '*', '/']

def generate_expressions(num_operators):
    if num_operators == 0:
        yield 'F3'
    else:
        for rec in generate_expressions(num_operators - 1):
            for op in OPERATORS:
                yield rec + op + 'F3'

def E(num_operators):
    total = 0
    count = 0
    for ex in generate_expressions(num_operators):
        total += eval(ex)
        count += 1
    return total / count

With this brute-force approach, I get:

*

*$E(0) = 3$

*$E(1) = 4$

*$E(2) = \frac{29}{6}$

*$E(3) = \frac{199}{36}$

*$E(4) = \frac{1319}{216}$

*$E(5) = \frac{8539}{1296}$

*$E(6) = \frac{54359}{7776}$

*$E(7) = \frac{341779}{46656}$

*$E(8) = \frac{2128799}{279936}$

*$E(9) = \frac{13163419}{1679616}$

*$E(10) = \frac{80933639}{10077696}$
After this point, the $O(4^n)$ running time of this naïve algorithm becomes unbearable, so I'll stop there.
But I already see a pattern: For $n \ge 2$, $E(n)$'s denominator is a power of 6.  Now, can we find a formula for the numerator?
