For example: the function f(x)=1/x has f(f(x))=x

There are also functions that when iterated thrice become the identity.

For example: The function f(x)=1/(1-x) has f(f(x))=(x-1)/x and f(f(f(x)))=f^{3}(x)=x.

Are there functions for other values of n (or perhaps all values of n) where f^{n}(x)=x but f^{m}(x)≠x for any m<n?