$f: X \mapsto X$ is a function with $f^n =\operatorname{ id}_X$ for a $n \geq 1$. Prove that $f$ is a bijection. The problem above is easy to see with $n = 1$, because then every element of $X$ maps to itself and the function $f$ is obviously bijective. By $n = 2$ we have for every $x \in X$
one $y \in X$ s.t. $(x) = y, f(y) = x$. So every element of $X$ maps to exactly one other element of $X$ and $f$ is thus bijective.
However, the proof does not cover all $n \geq 1$, but only the first two $n's$. Is there a better possiblility to make a proof that covers all $n \geq 1$?
 A: $f^{n-1}$, for $n > 1$ is the inverse (and if we define $f^0(x) = \operatorname{id}_X$ it also holds for $n=1$). And a function with an inverse is bijective.
[Added] More general statement: if $f: X \rightarrow Y$ and $g: Y \rightarrow X$ are functions such that $gf = \operatorname{id}_X$ and $fg = \operatorname{id}_Y$ then $f$ is bijective (and $g$ too, by symmetry). $g$ is called the inverse of $f$, and $f$ the inverse of $g$. Proof: Suppose $f(x_1) = f(x_2)$, then $x_2 = g(f(x_2)) = g(f(x_1)) = x_1$, so $f$ is injective (1-1). And if $y$ is in $Y$, then $f(g(y)) = y$, so $y \in f[X]$ and $f$ is surjective (onto). 
In the case at hand, $g = f^{n-1}$ will do. 
A: If $f$ is not one to one then there exists $x_1 \neq x_2$ such that $$f(x_1)=f(x_2)$$ so $$f^n(x_1)=f^n(x_2)$$ and therefore $$x_1=x_2$$ which is contradiction.
If $f$ is not onto then $f^n(X)$ will be a proper subset of $X$ wich is contradiction.
A: Denote $g := f^{n-1}.$ Then $gf = fg = 1_X \Rightarrow g, f : X \rightarrow X$ are both bijective.
A: Still another way:  you can use this more general resul from set theory:

Let $g: A\longrightarrow B $, $\:h:B\longrightarrow C$ be maps.
  
  
*
  
*If $h\circ g$ is injective, $g$ is injective.
  
*If $h\circ g$ is surjective, $h$ is surjective.
  

Here, you can write $f^n=f\circ f^{n-1}=f^{n-1}\circ f$ for $n>1$ (the case $n=1$ being trivial).
