As the wiki now explains, (1, 1) -> (9, 3) -> (3, 1) -> (na, nb) -> (a, b), originally found by me, is the "mathematical" approach you seek (it works for any a, b)