Find the remainder when 3^997

is divided by 5.

n=1 3n/5=3/5
n=2 3^2=9/25
n=3 3^3=27/5
n=4 3^4=81/5
n=5 3^5=243/5

r=3,4,2,1,3,4,2,1
n=997

Note that the last digit of 3^n repeats:

3,9,7,1,...
3^997 = 3^996*3, so it ends in 3
so, ...

you were on the right track.

look at these two columns

n r , where r is the remainder after dividing by 5
1 3
2 4
3 2
4 1
5 3
6 4
7 2

8 1
9 3
10 4
11 2
12 1

So the remainders cycle as 3 4 2 1,

so if n is evenly divisible by 4 , the remainder of 3^n divided by 5 will be 1
if n divided by 4 leaves a remainder of 1, such as n=5 or n=9 , the remainder of 3^n divided by 5 will be 3

if n divided by 4 leaves a remainder of 2, such as n=6 or n=10 , the remainder of 3^n divided by 5 will be 4

if n divided by 4 leaves a remainder of 3, such as n=7 or n=11 , the remainder of 3^n divided by 5 will be 2

So 997 ÷ 4 leaves a remainder of 1
so 3^997 leaves a remainder of 3 when divided by 5

To find the remainder when 3^997 is divided by 5, we need to look for a pattern in the remainders obtained when we divide the powers of 3 by 5.

Let's calculate the remainders for the first few powers of 3:
3^1 = 3, remainder = 3
3^2 = 9, remainder = 4
3^3 = 27, remainder = 2
3^4 = 81, remainder = 1
3^5 = 243, remainder = 3
...

Notice that the remainders repeat in a pattern: 3, 4, 2, 1, 3, 4, 2, 1, ...

To find the remainder when 3^997 is divided by 5, we can find the position of 997 in this repeating pattern. Since the pattern repeats every 4 powers of 3, we can divide 997 by 4 to find the quotient and remainder.

997 divided by 4 is 249 with a remainder of 1.
This means that 997 is equivalent to 249 sets of 4 powers of 3 plus the remainder 1.

Since the remainder is 1, the position of 3^997 in the repeating pattern is the second value, which is 4. Therefore, the remainder when 3^997 is divided by 5 is 4.