import Mathlib /-- A large power of x has the stated residue. -/ theorem congr_pow (x : ℤ) (h : x ≡ 3 [ZMOD 10]) : x ^ 18 ≡ 9 [ZMOD 10] := by refine (h.pow 18).trans ?_ norm_num [Int.ModEq] /-- The combined expression has the stated residue. -/ theorem congr_product (x y : ℤ) (hx : x ≡ 3 [ZMOD 10]) (hy : y ≡ 4 [ZMOD 10]) : x ^ 18 * y ^ 12 + 4 ≡ 8 [ZMOD 10] := by have h1 := congr_pow x hx have h2 : y ^ 12 ≡ 6 [ZMOD 10] := by refine (hy.pow 12).trans ?_ norm_num [Int.ModEq] refine ((h1.mul h2).add_right 4).trans ?_ norm_num [Int.ModEq]