Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the sum of i^3 mod 7 over i = 1 to 20?

  1. A. 64
  2. B. 65
  3. C. 63
  4. D. 67

Correct answer: C. 63

Cubes mod 7 cycle through 1, 1, 6, 1, 6, 6, 0 with period 7; each full period sums to 21 and the leftover terms are added separately.

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

Exams that ask this topic