Data Structures & AlgorithmsModerateICPC regional · GATE CS

Problem: Compute σ(360), the sum of all positive divisors of 360.

  1. A. 810
  2. B. 24
  3. C. 1170
  4. D. 540

Correct answer: C. 1170

360 = 2³ · 3² · 5 and σ is multiplicative: (1 + 2 + 4 + 8)(1 + 3 + 9)(1 + 5) = 15 · 13 · 6 = 1170. Excluding 360 itself gives 810, counting divisors gives 24, and multiplying (p^k + 1) terms (9 · 10 · 6) gives 540.

More Coding Interview Problems questions

Exams that ask this topic