🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Posets, Lattices and Groups: all 10 questions

Quiz: Posets, Lattices and Groups · Question 9 of 10

What does this print? (code)

What does this print?

k, x = 1, 2
while x != 1:
    x = x * 2 % 5
    k += 1
print(k)
  1. A.2
  2. B.3
  3. C.4
  4. D.5
Answer & explanation

Correct answer: 4

Powers of 2 mod 5 are 2, 4, 3, 1, so the order of 2 in ({1, 2, 3, 4}, × mod 5) is 4 — a generator of the group.

Can you get the rest right without peeking?

Take the timed Quiz: Posets, Lattices and Groups quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →