<s>[INST] How to evaluate below expression of modular arithmetic? How to evaluate (10^18)%(10^9 + 7) using modular arithmetic? How to proceed and what will be the steps?
 [/INST] (10^9 + 7) * (10^9 - k) = 10^18 + 7*10^9 - k*10^9 - 7k
k=7: (10^9 + 7) * (10^9 - 7) = 10^18 - 49
10^18 = (10^9 + 7) * (10^9 - 7) + 49
10^18 % (10^9 + 7) = 49

Thought process:
The form of this problem is a^2 % (a+k).
Recall (a+k)*(a-k) = a^2 - k^2
So a^2 % (a+k) = k^2 % (a+k)
Now because k is so small, k^2 % (a+k) = k^2.

</s>