<s>[INST] A trick for calculating $n^6$ that I don't understand I was doing a math exercise and it asked to find what are the possible units digits of $n^6$ knowing that $n\in\mathbb Z$. The solution said that because we are concerned only with finding what the units digits of $n^6$ could be, it is sufficient to take the sixth power of numbers $0,1,2,\dots,9$ and the results would be our answers (which are $0,1,4,5,6,9$). How come this is true? Thanks for your help!
 [/INST] What is the units digit of $340274513\times 384759374\,{}$?
$$
\begin{array}{ccccccccccccc}
& & & & 3 & 4 & 0 & 2 & 7 & 4 & 5 & 1 & 3 \\
& & & \times & 3 & 8 & 4 & 7 & 5 & 9 & 3 & 7 & 4 \\
\hline
& & & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 2 \\
& & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
& \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
\cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
& & & \vdots \\
& & & \vdots \\
\hline
\cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 2   
\end{array}
$$
The method of multiplying that you learned as a child shows you that the units digit in the product is determined by the units digits, and not any of the other digits, in the numbers that you're multiplying.
Moreover you can write the number $340274513$ as $\Big(34027451\times10\Big)+3$ and $384759374$ as $\Big(38475937\times 10\Big)+4$, and then you have
\begin{align}
& 340274513\times384759374 \\[10pt]
= {} &  \Big(\big(34027451\times10\big)+3\Big)\times\Big(\big(384759374\times10\big)+4\Big) \\[10pt]
= {} & \Big(\underbrace{\text{something}\times 10}_{\begin{smallmatrix} \text{This contributes} \\  \text{nothing to the} \\  \text{units digit.} \end{smallmatrix}}\Big) + (3\times 4)
\end{align}
</s>