Questions tagged [gcd-and-lcm]

For questions related to gcd (greatest common divisor, also known as the hcf, the highest common factor), lcm (least common multiple), and related concepts from integer and ring theory.

The greatest common divisor (also known as highest common factor) of two or more integers is the largest integer that divides all of them. It may be computed using the Euclidean algorithm.

Bézout's identity states that for non-zero integers $a$ and $b$ there exist integers $x$ and $y$ with $ax+by=\gcd(a,b)$.


If $a, b \in \mathbb{N}$, write $a \mid b$ if $a$ divides $b$, i.e. there is $k \in \mathbb{N}$ such that $b = ka$.

The least (or lowest) common multiple of $a_1, \dots, a_k \in \mathbb{N}$ is the smallest positive integer $N$ such that $a_i \mid N$ for $i = 1, \dots, k$. We usually denote $N$ by $\operatorname{lcm}(a_1, \dots, a_k)$. Note that $\operatorname{lcm}(a_1, \dots, a_k)$ can be defined recursively from a binary definition. That is,

$$\operatorname{lcm}(a_1, \dots, a_k) = \operatorname{lcm}(\operatorname{lcm}(\dots\operatorname{lcm}(\operatorname{lcm}(a_1, a_2), a_3), \dots, a_{k-1}), a_k).$$

If $a, b \in \mathbb{N}$ and $a = p_1^{r_1}\dots p_m^{r_m}$, $b = p_1^{s_1}\dots p_m^{s_n}$ are their prime decompositions (where some of the $r_i$ and $s_j$ can be zero), we have

$$\operatorname{lcm}(a, b) = p_1^{\max(r_1, s_1)}\dots\ p_m^{\max(r_m, s_m)}.$$

Note that $\operatorname{lcm}(a, b)\operatorname{gcd}(a, b) = ab$.


These notions can be generalised to any commutative ring; the above is just the particular case of (positive elements of) the ring $\mathbb{Z}$.

2686 questions
5
votes
0 answers

If two numbers $a$ and $b$ are coprime, then $ab$ and $a^2+b^2$ are also coprime. Why is this true?

I read a proof that simply stated the second part follows from the first. I do not see how.
4
votes
3 answers

What is GCD of $7^{3001}-1$ and $7^{3000}+1$?

Find GCD of $7^{3001}-1$ and $7^{3000}+1$. My work. I noted that $(1)(7^{3001}-1) -(7)(7^{3000}+1)=-8$.
Raviraz
  • 55
  • 5
4
votes
1 answer

Find the greatest common divisor of the polynomials $ \ f(x)=x^{3}+2 \ \ and \ \ g(x)=x- 1 \ $ over the field $ \ \ \mathbb{Z}_{3}$

Find the greatest common divisor of the polynomials $ \ f(x)=x^{3}+2 \ \ and \ \ g(x)=x- 1 \ $ over the field $ \ \ \mathbb{Z}_{3}$. $$ $$ We have $ \ f(x)=x^{3}+2 \ \ and \ \ g(x)=x-1=x+2 \ \ \ mod \ (3) \ $ . Now $ \ x^{3}+2=(x+2)(x^{2}-2x+4) \…
MAS
  • 10,638
4
votes
1 answer

Let $m$ and $n$ be positive integers such that $\gcd(m,n)=1.$Compute $\gcd(5^m+7^m,5^n+7^n)$.

Problem: Let $m$ and $n$ be positive integers such that $\gcd(m,n)=1.$Compute $\gcd(5^m+7^m,5^n+7^n)$. My Attempt: I wrote a simple computer program and deduced that $\gcd(5^m+7^m,5^n+7^n)=2$ if $m+n$ is odd and $\gcd(5^m+7^m,5^n+7^n)=12$ if $m+n$…
Student
  • 9,196
  • 8
  • 35
  • 81
3
votes
0 answers

Carmichael number n such that $\frac{\gcd(n-1, \phi(n))^2}{\lambda(n)^2} \geq n-1$.

Such that $\phi(n)$ is a phi Euler function, $\lambda(n)$ is a Carmichael lambda function. With $\frac{\gcd(n-1, \phi(n))^3}{\lambda(n)^3} \geq n-1$, i can find some numbers n such as: $1729, 19683001, 631071001, 4579461601, 8494657921$ and so on,…
Visage Livre
  • 161
  • 6
3
votes
2 answers

Find the required gcd

Question: Let $\gcd(a,n)=d_1\gt 1$ and $\gcd(b,n)=d_2\gt 1$, given that $\gcd(d_1,d_2)=1$, find $\gcd(a+b,n)$. My try Since $\gcd(a,n)=d_1$ so $a=pd_1$ and since $\gcd(b,n)=d_2$ so $b=qd_2$. My guess is since the greatest common divisors of $a,b$…
Charlotte
  • 1,674
3
votes
2 answers

if a|b and a>0 then gcd(a,b)=a

Is this proof right? Prove: if a|b and a>0 then gcd(a,b)=a. Let a|b and the GCD(a,b) = m, then b=aq for some integer q and the GCD(a,b) can be expressed as a linear combination with some integer x and y, ax + by = m…
3
votes
3 answers

If $\gcd (a, bc) = d$ and $\gcd(a, b) = 1$, then $\gcd(a, c) = d $

I have proceeded to as far as declaring these with EEA but I do not know how to show that $d \mid c$ for the conclusion. Any help to go to this direction will be greatly appreciated.
2
votes
1 answer

Given $N = lcm(A,B)+lcm(B,C)+lcm(C,A)$, Prove that N cannot be a power of 2

I was doing a codechef question https://www.codechef.com/problems/LCMMANIA which asks us to find, three numbers $A, B, C$ such that given $N$: $N = lcm(A, B) + lcm(B, C) + lcm(C, A)$ While solving the question i made an observation that if $N$ is a…
2
votes
1 answer

Nearest overlapping time for periodic flashing light bulbs

Assume that we have two light bulbs in the room. Each bulb turns ON at fixed periodic intervals and stays ON for fix time period before turning OFF. The ON time is part of the periodic interval; ON time + OFF time = 1 cycle. Let's call them Bulb A…
niil87
  • 29
2
votes
0 answers

Bezout's coefficients for univariate polynomials that are known to be co-prime

It is known that the half-GCD algorithm (https://www.csd.uwo.ca/~mmorenom/CS424/Lectures/FastDivisionAndGcd.html/node6.html) can be used for computing the Bezout's coefficients $a,b$ so that $ap + bq \equiv 1$ for two univariate polynomials $p$ and…
Sean
  • 21
2
votes
0 answers

Suppose $x,y,z$ are mutually coprime positive integers that solve $x^2+y^2=z^2$

Suppose $x,y,z$ are mutually coprime positive integers that solve $x^2+y^2=z^2$.Assume that $x$ is odd and exactly one of $y$ or $z$ is even. Show that $z-y$ and $z+y$ are coprime. So I started of by saying since $x$ is odd $x^2$ is…
nikoa
  • 31
2
votes
1 answer

Find $x,y$ if LCM $= x+y$ and HCF $= x-y$

I have been struggling on this homework question for quite a while. Find $x,y$ if LCM $= x+y$ and HCF $= x-y$ Here is my working: Since, LCM $\times$ HCF $= xy$, $$ (x+y)(x-y) = xy \\ x^2 - y^2 = xy $$ I am stuck here...
athrb
  • 51
2
votes
1 answer

Not knowing the $\mathrm{gcd}$ and $\mathrm{lcm}$ and knowing $\mathrm{gcd+lcm}$, how to find $a$ and $b$ in $\mathrm{gcd}(a,b)$?

Here's what we have: $\mathrm{gcd}(a,b)=d$ ; $\mathrm{lcm}(a,b)=m$ ; $a+b=30$ ; $m+d=42$ ; $b>a$. What I tried: if $d$ divides $a$ and $b$ so it divides $a+b$ so $d$ divides $30$. And with $\mathrm{gcd}$ and $\mathrm{lcm}$ rules I found that…
18.99
  • 69
2
votes
1 answer

Hackerrank: Between Two Sets

This is the problem statement: You will be given two arrays of integers and asked to determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being considered The integer…
1
2 3
11 12