GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many functions f : {1, …, 6} → {1, …, 6} satisfy f(f(f(x))) = f(x) for every x?

  1. A. 1057
  2. B. 13806
  3. C. 4752
  4. D. 5902

Correct answer: D. 5902

Let I be the image, |I| = k. For y = f(x) ∈ I the condition says f(f(y)) = y, so f permutes I as an involution; points outside I map anywhere into I. Count = Σ C(6,k)·inv(k)·k^(6−k) with inv = 1, 2, 4, 10, 26, 76: 6 + 15·2·16 + 20·4·27 + 15·10·16 + 6·26·5 + 76 = 5902 (requiring f∘f = f instead gives 1057).

More Discrete Mathematics questions

Exams that ask this topic