Assume a solution
$ f\left(x\right) \propto \exp\left(\lambda x\right), $ which gives $ \lambda^n = \pm k^2. $ Now let $ \lambda = k^{2/n} \exp\left(i r\right), $ so that $ \lambda^n = k^2 \exp\left(i n r\right) = \pm k^2 \Rightarrow \exp\left(i n r\right) = \pm 1. $ If $+1$, $ r_m = \frac{2 \pi}{n} m, $ where $m = 0, 1, ..., n - 1$.
If $-1$, $ r_m = \frac{\pi}{n} \left(2m+1\right), $ where $m = 0, 1, ..., n - 1$.
Your solution is then $ f\left(x\right) = \sum_{m=0}^{n-1} a_m \exp\left[k^{2/n} \exp\left(i r_m\right) x\right], $ where $a_m$'s are determined with $n$ initial conditions and the correct $r_m$'s are used based on whether it is $+1$ or $-1$.
You can check this for the simple harmonic oscillator ($n = 2$, and the $-1$ case).