Doubt from one of the quora examples

Question:

If the integers m and n are chosen at random between 1 and 100, then find the probability that

7^m+7^n

is divisible by 5.

I approached this way-

The last digits of the powers of 7 follow the pattern

7,9,3,1,7,9,3,1,...

For 7^m+7^n to be divisible by 5, its units digit should be 0 or 5

this happens when the last digits are 7+3=10 or 9+1=10. So the two powers must have the same parity, but they must be different powers. For even powers,

7^2,7^4,7^6,...,7^{100}

there are 50 even powers. Their last digits follow the pattern : 9,1,9,1,…

Similarly, for odd powers,

7^1,7^3,7^5,\ldots,7^{99}

there are 50 odd powers and their last digits follow the 7,3,7,3,.. pattern

I am getting stuck after this. I can’t figure out how to correctly count the number of (m,n) pairs that actually satisfy this condition. How to count the number of valid pairs (m,n) and is my approach even valid?

Your approach is correct. You just need to count the pairs now.

The last digits of 7^n repeat in a cyclic pattern of length 4:

7, 9, 3, 1, 7, 9, 3, 1, \ldots

For the sum 7^m + 7^n to be divisible by 5, the sum of their last digits must end in 0. This gives two possible combinations for the units digits:

7 + 3 = 10 \quad \text{or} \quad 9 + 1 = 10

For the range 1 \le m, n \le 100, there are exactly 25 powers ending in 7, 25 ending in 9, 25 ending in 3, and 25 ending in 1.

Thus, the valid ordered pairs for the ending digits are:

(7,3), (3,7), (9,1), (1,9)

Each specific pair yields 25 \times 25 = 625 valid pairs of (m,n).

Hence, the total number of valid pairs is:

4 \times 625 = 2500

The total possible pairs of (m,n) from the sample space is:

100 \times 100 = 10000

Therefore, the required probability P is:

P = \frac{2500}{10000} = \frac{1}{4}