Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

What is the sum of a_n = n mod 7 for n from 1 to 20 inclusive?

  1. A. 64
  2. B. 63
  3. C. 62
  4. D. 30

Correct answer: B. 63

Blocks n = 1 to 6, 8 to 13 and 15 to 20 each contribute 1 + 2 + ... + 6 = 21, and the multiples of 7 contribute 0, so the total is 63.

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

Exams that ask this topic