Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the value of the expression (1^2) + (2^2) + ... + (50^2) modulo 7?

  1. A. 1
  2. B. 2
  3. C. {C+5}
  4. D. 4

Correct answer: A. 1

Reduce each square modulo 7 first; squares repeat with period 7, so each block of seven terms contributes the same residue.

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

Exams that ask this topic