Greatest Common Divisor
GCD calculation in ordinary maths is used to find whether two numbers are relatively prime. This means that two numbers have no factors in common. In other words telling that the two numbers ratio is a simplified fraction.
This is done by;
1. Get the smaller ratio between numbers
2. If the ratio remainder is zero the lower value is the answer
3. Else continue the above two steps with the smaller number and (greater number % smaller number) this is modulo division where you get the remainder.
This is done by;
1. Get the smaller ratio between numbers
2. If the ratio remainder is zero the lower value is the answer
3. Else continue the above two steps with the smaller number and (greater number % smaller number) this is modulo division where you get the remainder.
Comments
Post a Comment