Which NumPy function is used to find the Least Common Multiple (LCM) of two numbers?
A
np.lcm() B
np.least_common_multiple() C
np.lcm.reduce() D
np.gcd()
Analysis & Theory
`np.lcm()` returns the least common multiple of two scalar values or arrays.
What is the result of `np.lcm(4, 6)`?
A
2 B
12 C
24 D
6
Analysis & Theory
The LCM of 4 and 6 is 12.
Which function is used to find the LCM of all elements in an array?
A
np.lcm() B
np.lcm.reduce() C
np.lcm.accumulate() D
np.gcd.reduce()
Analysis & Theory
`np.lcm.reduce(array)` computes the LCM of all array elements.
What is the result of `np.lcm.reduce([2, 3, 4])`?
A
6 B
8 C
12 D
24
Analysis & Theory
LCM of 2 and 3 is 6, LCM of 6 and 4 is 12.
What will `np.lcm(0, 10)` return?
A
0 B
10 C
1 D
Raises an error
Analysis & Theory
LCM involving 0 returns 0, as per NumPy's convention.
Which NumPy function is the counterpart to `np.lcm()` for finding the greatest common divisor?
A
np.hcf() B
np.gcd() C
np.common_divisor() D
np.lcm.inverse()
Analysis & Theory
`np.gcd()` computes the greatest common divisor (GCD) of values.
What is the result of `np.lcm.reduce([5, 0, 10])`?
A
10 B
0 C
5 D
Raises an error
Analysis & Theory
LCM involving 0 results in 0.