All tools
Greatest common divisor
Processed in this browser. Nothing is uploaded.
Example
Example: A = 12, B = 18 → 6
Maximum 1,000,000 characters.
How to use this result
Find the greatest common divisor of two integers: the largest nonnegative integer that divides both inputs in ordinary nonzero cases. Use it when reducing fractions or dividing quantities into equal groups.
Worked example
a: 12 b: 18
6
Limits and edge cases
Negative inputs are treated by their absolute values. Inputs must be safe integers. With one zero, the other input’s absolute value is returned; for two zeros this implementation returns 0 as a convention.