• GCD of a set of numbers can be thought as a blue-print of those numbers. If u keep adding the GCD you can make all numbers that belong in that set.
• Every common divisor of a and b is a divisor of gcd(a,b).
• Gcd(a,b) where both a and b are non-zero, can also be defined as the smallest positive integer d which can be a solution/which can be expressed as a linear combination of a and b in the form d=a*p + b*q, where both p and q are integers.
• Gcd(a, 0) = |a|, for a ≠ 0, since any number is a divisor of 0, and the greatest divisor of a is |a|.
• If 'a' divides b*c and gcd(a,b)=d , then a/d divides c.
• If m is a non-negative integer, then gcd(m⋅a, m⋅b) = m⋅gcd(a, b).It also follows from this property that if gcd(a,b)=g, then a/g and b/g should be coprime. Try to derive it yourslef.
• If m is any integer gcd(a,b)=gcd(a+m*b,b).
• The GCD: gcd(a, b) = gcd(b, a%b).
• If m is a positive common divisor of a and b, then gcd(a/m, b/m) = gcd(a, b)/m.
• GCD is a multiplicative function. That is if a1 and a2 are coprime gcd(a1*a2,b)=gcd(a1,b)*gcd(a2,b). -1. In particular, recalling that GCD is a positive integer valued function we obtain that gcd(a, b⋅c) = 1 if and only if gcd(a, b) = 1 and gcd(a, c) = 1. if the gcd is one then they need not be coprime to distribute the gcd, morever each gcd invidually should also be 1.
• The GCD is a commutative function: gcd(a, b) = gcd(b, a).
• The GCD is an associative function: gcd(a, gcd(b, c)) = gcd(gcd(a, b), c). Thus gcd(a, b, c, ...) can be used to denote the GCD of multiple arguments.
• gcd(a, b) is closely related to the least common multiple lcm(a, b): we have gcd(a, b)⋅lcm(a, b) = |a⋅b|.
• The following versions of distributivity hold true: gcd(a, lcm(b, c)) = lcm(gcd(a, b), gcd(a, c)) lcm(a, gcd(b, c)) = gcd(lcm(a, b), lcm(a, c)).
• If we have the unique prime factorizations of a = p1^e1*p2^e2 ⋅⋅⋅ pm^em and b = p1^f1*p2^f2 ⋅⋅⋅ pm^fm where ei ≥ 0 and fi ≥ 0, then the GCD of a and b is gcd(a,b) = p1^min(e1,f1) p2^min(e2,f2) ⋅⋅⋅ pm^min(em,fm).
• In a Cartesian coordinate system, gcd(a, b) can be interpreted as the number of segments between points with integral coordinates on the straight line segment joining the points (0, 0) and (a, b).
• For non-negative integers a and b, where a and b are not both zero, provable by considering the Euclidean algorithm in base n it simple states that: gcd(n^a-1,n^b-1)=n^gcd(a,b)-1
If u want an informal proof think of numbers in base 2 .We are calculating gcd's of number which contains all continuous 1 in their binary representations.. For ex: 001111 000011 their gcd can be the greatest common length which in this case is 2 thus the gcd becomes:000011 .Think of numbers in terms of length maybe you get the idea.
• An identity involving Euler's totient function: Gcd(a,b)=∑φ(k) where k are all common divisors of 'a' and 'b'









This is pretty good and helpful.
didn't understand the one before the last
the formatting ruined it: it simple states that:gcd(n^a-1,n^b-1)=n^gcd(a,b)-1
If u want an informal proof think of numbers in base 2 .We are calculating gcds of number which contains all continuous 1 in their binary representations.. For ex: 001111 000011 their gcd can be the greates common length which in this case is 2 thus the gcd becomes:000011 .Think of numbers in terms of length maybe you get the idea
Here's an interesting formula of $$$\gcd$$$ and Fibonacci number:
This relation is pretty interesting :)
Important GCD properties we will use are
Let assume $$$a \gt b$$$, the base cases are $$$F_{0}=0$$$, $$$F_{1}=1$$$ and $$$F_{2}=1$$$ .
Claim $$$I$$$ : Every 2 consecutive Fibonacci numbers will always be co-prime $$$gcd(F_{a+1},F_{a})=1$$$.
Proof $$$I$$$ : Using $$$1$$$-st GCD property we can say,
we back to $$$gcd(F_{a},F_{a-1})$$$ same relation just 1 step down and by induction we can bring it finally down to $$$gcd(F_{2},F_{1}) = 1$$$, which proves our claim.
Claim $$$II$$$ : $$$gcd(F_{a},F_{b}) = gcd(F_{a-b},F_{b})$$$
We know $$$F_{a+1}$$$ and $$$F_{a}$$$ are co-prime, lets start by counting $$$F_{a+1}$$$ after decaying of $$$F_{a+ \Delta}$$$ and use $$$3$$$-rd GCD property to comment on $$$\Delta$$$ which diretly relates to $$$a-b$$$ in our claim.
We are ignoring count of $$$F_{a}$$$ after decaying of $$$F_{a+ \Delta}$$$ because we can always erase its presense using $$$1$$$-st GCD property.
Lets start counting simple,
Case $$$1$$$ : $$$gcd(F_{a+2},F_{a})$$$ , lets count how much
which gives us $$$1$$$,
Case $$$2$$$ : $$$gcd(F_{a+3},F_{a})$$$ , lets count how much
which gives us $$$2$$$,
Case $$$3$$$ : $$$gcd(F_{a+4},F_{a})$$$ , lets count how much
which gives us $$$3$$$, For case $$$4$$$ you will get count = $$$5$$$,
Hmm. . . . now we can see $$$Cnt_{x} = Cnt_{x-1} + Cnt_{x-2}$$$, count given by 2 decays, which is also Fibonacci number, which gives us $$$Cnt_{\Delta} = F_{\Delta}$$$.
If we see cleverly $$$Cnt_{x} = Cnt_{x-1} + Cnt_{x-2}$$$, count given by 2 decays which is also Fibonacci number, which gives us $$$Cnt_{\Delta} = F_{\Delta}$$$.
Now lets bring $$$b$$$ and $$$a$$$ into picture like we used in our Claim $$$II$$$, where $$$a = b + \Delta$$$.
which proves our claim.
Corollary from Claim $$$II$$$ : $$$gcd(F_{a},F_{b}) = gcd(F_{b},F_{a \% b})$$$ , from GCD property $$$1$$$ we can keep on subtracting $$$b$$$ till $$$a-kb \geq 0$$$ which gives us $$$a \% b$$$ at the end.
Final Steps :
which proves the interesting relation between $$$gcd$$$ and Fibonacci.
Evergreen post
When solving 664A - Complicated GCD then how to input 10^100 digits in C program?
Explain the data types of C...
What's the GCD of n,n+1?
gcd(n,n+1) == 1;
...
LET'S Assume that n is even the n+1 must be odd and we know that the gcd of odd and even number is 1`
uh, this is blatantly wrong
GCD of an odd and an even number is NOT neccessarily 1. Take for example 6 and 15.
Let n >= 1 We claim that gcd(n, n + 1) = 1
We prove the claim via contradiction. Let gcd(n, n + 1) = r. It can be proved that r >= 1.
Assume that r != 1. This implies that r > 1 since r >= 1.
We can see that r | n and r | n + 1. This directly implies that there are integers x and y such that
n = x * r and n + 1 = y * r.
Subtracting both the equations, we get
1 = r * (y — x)
We can conclude from this equation that y — x = 1 and r = 1 since r >= 0
This is a contradiction since r > 1. QED.
An easier proof is from the following property: gcd(a,b) = 1 iff p*a + q*b = 1 where p,q are integers. Now, (-1)*n + 1*(n+1) = 1 Hence, gcd(n, n+1) = 1 QED
for more easier proof you can use the euclidian algorithm: gcd(n, n+1) = gcd(n+1-n, n-n) = gcd(1, 0) = 1
Note what it want you to solve. Not the $$$\gcd(a,b)$$$ but……
Let a, b be integers.
Then c = gcd(a,b) iff
c|a and c|b
if x|a and x|b then x|c
(Here, x|y means "x divides y" or equivalently, y = nx for some integer n)
Note: There can be two gcd's of a and b, one positive and the other negative. We take the positive one as the "true" gcd.
gcd(a*b, c) = gcd(a,c)*gcd(b,c)/gcd(a,b,c)
It can be proved by decomposing each number into disjoint parts that cover all commonality.
a = p*x*y*t, b = q*x*z*t, c = r*y*z*t. Here p, q, and r are unique to a, b, and c respectively. t is common to all. x, y and z are common to a pair but not to all three. now it just becomes caluclations.
gcd(a, c) = y*t, gcd(b, c) = z*t, gcd(a, b, c) = t, gcd(a*b, c) = gcd(a*b, c) = y*z*t. RHS = (y*t)*(z*t)/t = y*z*t = RHS
This was super helpful, reading all the properties along with their proofs was really enjoyable. Thanks for sharing this blog.