coolpintu wrote:

Can someone please explain me in detail how we arrived at the problem? I solved the Q for unit digit of the expression. Is this approach wrong? How to arrive at the solution?

Unit digit is remainder when divided by 10, what we are asked is remainder when we divide the no. by 7, so finding unit unit digit wont help you.

A rule:

If a when divided by b leaves remainder c,

then, a^x, when divided by b will leave the remainder c^x.

So, to approach the problem, we can start from raised to power 1, and go on and stop when we get 1 or -1 as remainder, then it becomes easy to solve it.

Like in this case, 3^3 leaves remainder -1 when divided by 7,

so using the above rule, we can say that 3^1989 = (3^3)^ 663 will leave remainder (-1)^663 or -1, when divided by 7.