The remainder when $2^{164}$ is divided by 7 is 4.

Correct solutions came from Alex and Neil of Madras College, St Andrews, who on investigating 2 raised to the power $n$, discovered that the sequence 1,2,4,1,2,4... occurs for increasing values of $n$ which led them to prove their conjectures that:

$$\eqalign{ 2^{3n} \equiv 1 &\text{(mod 7)} \\ 2^{3n+1} \equiv 2 &\text{(mod 7)} \\ 2^{3n+2} \equiv 4 &\text{(mod 7)}}$$

It was Luke, also of Madras College , who went on to investigate 2 raised to the power $n$, (mod $p$) where $p$ is prime. Extending the work of Alex and Neil i.e. 2 raised to the power $n$, (mod 7) which has a period of 3. Luke found that any prime $p$ which can be written in the form $8k+1$ or $8k-1$ has a period less than or equal to $(p-1)/2$, this conclusion holding for $k$ belonging to the set of positive integers and $$2^{p-1} \equiv 1 \text{(mod 7)}$$