Question 1
EasyWhat is the GCD of 48 and 18?
- A.
9
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What is the GCD of 48 and 18?
9
3
12
6
Answer: D
Euclid: gcd(48, 18) = gcd(18, 12) = gcd(12, 6) = gcd(6, 0) = 6.
What is the LCM of 4 and 6?
12
24
2
10
Answer: A
lcm(a, b) = a × b / gcd(a, b) = 24 / 2 = 12.
Which of these numbers is prime?
27
33
21
29
Answer: D
29 has no divisors other than 1 and itself; 21 = 3 × 7, 27 = 3³, 33 = 3 × 11.
What is the output of this code?
print(17 % 5)
0
2
1
3
Answer: B
% gives the remainder: 17 = 3 × 5 + 2, so 17 % 5 is 2.
To check whether n is prime by trial division, up to which number must you test divisors?
n − 1
√n
log n
n/2
Answer: B
If n = a × b with a ≤ b, then a ≤ √n, so any factor pair has a member at most √n.
What is 0! (zero factorial)?
0
Undefined
−1
1
Answer: D
By definition 0! = 1, which keeps formulas like C(n, 0) = 1 consistent.
What is the output of this code?
import math
print(math.gcd(24, 18))
3
12
36
6
Answer: D
math.gcd returns the greatest common divisor: 24 = 2³ × 3 and 18 = 2 × 3², so gcd = 2 × 3 = 6.
Is 1 a prime number?
Yes
It is both prime and composite
Only in some countries
No
Answer: D
A prime has exactly two divisors; 1 has only one.
Two numbers are co-prime. What is their GCD?
The smaller number
1
0
Their product
Answer: B
Co-prime numbers share no factor other than 1.
Using Euclid's algorithm, what is gcd(84, 36)?
6
4
36
12
Answer: D
gcd(84, 36) = gcd(36, 12) = gcd(12, 0) = 12.