Lemma. Characterisation of common divisors [01DW]

For all positive integers m and n, we have \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \begin {cases} \mathsf {D}{\mathopen {}\left (n\right )\mathclose {}} &\text {if } n\mid m \\ \mathsf {CD}{\mathopen {}\left (n,\operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}}\right )\mathclose {}} &\text {otherwise} \end {cases}