Data Structures & AlgorithmsHardGATE CS · ICPC regional

How many integers n in [1, 60] satisfy n^2 - n divisible by 6?

  1. A. 41
  2. B. 42
  3. C. 44
  4. D. 40

Correct answer: D. 40

n^2 - n = n(n-1) is always even, so the test is divisibility by 3; n(n-1) is divisible by 3 exactly when n is 0 or 1 modulo 3.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic