Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT
Problem: What is the largest power of 2 that divides 480 × 36?
- A. 128
- B. 7
- C. 32
- D. 1024
Correct answer: A. 128
480 = 2⁵ · 15 and 36 = 2² · 9, so the product has 2^(5 + 2) = 2⁷ = 128 as its largest power-of-2 divisor. Reporting the exponent gives 7, using only 480's factor gives 32, and multiplying the exponents instead of adding them gives 2¹⁰ = 1024.
More Coding Interview Problems questions
- Problem: How many pairs (a, b) with 1 ≤ a < b ≤ 20 satisfy gcd(a, b) = 1?
- Problem: Find the last digit (units digit) of 7^(7^7) in decimal.
- Problem: How many subsets of {3, 5, 7, 11, 13, 17} have a sum equal to 24 (the empty set is excluded since its sum is 0)?
- Problem: In how many ways can the number 12 be written as an ordered sum of parts each equal to 1, 2 or 3 (so 1+2+... and 2+1+... are…
- Problem: Trains arrive at times 900, 940, 950, 1100, 1500, 1800 and depart at 910, 1200, 1120, 1130, 1900, 2000 (all as 24-hour clock…
- Problem: The fractional knapsack has capacity 50 and items (value, weight): (60, 10), (100, 20), (120, 30). Items may be taken…