Solution (source code)

= Solution

Use <modular exponentiation> by <repeated squaring>:
$$
27\equiv6\pmod7,\quad27^2\equiv6^2\equiv1\pmod7,\quad27^4\equiv27^8\equiv27^{16}\equiv1\pmod7.
$$
Since $17=16+1$, multiply the indicated powers to obtain \b[$27^{17}\equiv6\pmod7$]. Only the <binary expansion> of the exponent determines which squared powers are multiplied.