

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions to practice test questions related to congruences, greatest common divisors (gcd), and least common multiples (lcm) for cs 1050c. Topics include the relationship between congruences and divisibility, finding gcd values for n and n+12, and proving functions are onto and one-to-one.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


(cncn− 1... c 1 c 0 ) 10 = c 0 + 10c 1 + 10^2 c 2 + 10^3 cc +... + 10ncn ≡ c 0 + 2c 1.
The congruence holds because 10 ≡ 2 and 10n^ ≡ 0 for n ≥ 2. We conclude that (cncn− 1... c 1 c 0 ) 10 is divisible by 4 (i.e. congruent to zero modulo 4) if and only if c 0 + 2c 1 is. 2
gcd(n, n + 12) = gcd(n, n + 12 − n) = gcd(n, 12).
This proves that gcd(n, n + 12) is a divisor of 12 for any n, i.e. it is an element of the set A = { 1 , 2 , 3 , 4 , 6 , 12 }. Conversely, any element a ∈ A is a value of gcd(n, n + 12) for some n, for example for n = a (because gcd(a, 12) = a as a is a divisor of 12). The list of all possible values is 1, 2 , 3 , 4 , 6 , 12. 2
First, let’s prove that g is onto. Take any c ∈ C. Then, h(c) is an element of D so it has to belong to the image of (onto function by assumptions) h ◦ g ◦ f : there exists an a ∈ A such that h ◦ g ◦ f (a) = h(g(f (a))) = h(c). Because h is a one-to-one function, g(f (a)) = c (value of h on both sides is the same!). We conclude that c is in the range of g (it’s the value of g at f (a)). We are done. Now we need to prove that g is one-to-one. Assume it is not. Then, there are b, b′^ ∈ B such that b 6 = b′^ and g(b) = g(b′). Since f is onto, there are a, a′^ ∈ A such that f (a) = b and f (a′) = b′. Obviously, a 6 = a′ (otherwise, the values of f at these elements would be the same but they happen to be b and b′). Moreover,
h◦g◦f (a) = h(g(f (a)) = h(g(b)) = h(g(b′)) = h(g(f (a′))) = h◦g◦f (a′).
This contradicts one-to-oneness of h ◦ g ◦ f. 2
gcd(a, a + 2) = gcd(a, 2) = 2
(this is because a is an even number so 2 is a common divisor. Clearly, there are no larger divisors). Now, from one of the theorems we proved in class,
2lcm(a, a + 2) = gcd(a, a + 2)lcm(a, a + 2) = a(a + 2).
We conclude that
lcm(a, a + 2) =
a(a + 2) 2