Let n be the integer such that \( 0 \le n < 31\) and \(3n \equiv 1 \pmod{31}\). What is \(\left(2^n\right)^3 - 2 \pmod{31}\)? Express your answer as an integer from 0 to 30, inclusive.
3n mod 31 = 1, solve for n
n = 31m + 21, where m =0, 1, 2, 3........etc.
The smallest n = 21
[(2^21)^3 - 2] mod 31 == 6