REDC(T) returns T·R−1 mod n using only multiplies, a mask (mod R), a shift (÷R), and one conditional subtract. Watch the low k bits cancel so the ÷R is exact.
junior.md and professional.md for the correctness proof.
Try an even n to watch the construction fail (n' undefined). Try larger k (a bigger R) to see how the low-bit cancellation scales.
Default n = 13, R = 16, a = 7, b = 9 reproduces the worked example in junior.md § Step-by-Step Walkthrough.