Find greatest common divisor (GCD) between two numbers


/ Published in: C
Save to your folder(s)

Let m and n be variables containing the two numbers.
If n is 0, then stop : m contains the GCD
Otherwise, compute the remainder when m is divided by n.
Copy n into m and copy the remainder into n.
Then repeat the process, starting with testing whether n is 0.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.