Let $ABC$ be an equilateral triangle. Find all positive integers $n$, for which the function $f$, defined on all points $M$ from the circle $S$ circumscribed to triangle $ABC$, defined by the formula $f:S \rightarrow R, f(M)=MA^n+MB^n+MC^n$, is a constant function.
1. **Define the problem and initial setup:**
   Let $ABC$ be an equilateral triangle with side length $a$. Let $S$ be the circumcircle of $\triangle ABC$ with radius $R$. We need to find all positive integers $n$ for which the function $f(M) = MA^n + MB^n + MC^n$ is constant for all points $M$ on $S$.

2. **Evaluate $f(M)$ at specific points:**
   - When $M = A$, we have:
     \[
     f(A) = MA^n + MB^n + MC^n = 0 + a^n + a^n = 2a^n
     \]
   - When $M = X$, the midpoint of the arc $BC$ not containing $A$, we have:
     \[
     f(X) = MA^n + MB^n + MC^n = 2R^n + (2R)^n = R^n(2 + 2^n)
     \]

3. **Relate $a$ and $R$ using the Law of Cosines:**
   By the Law of Cosines in $\triangle ABC$:
   \[
   a^2 = 2R^2 - 2R^2 \cos 120^\circ = 2R^2 + R^2 = 3R^2 \implies a = R\sqrt{3}
   \]

4. **Equate the expressions for $f(A)$ and $f(X)$:**
   \[
   2a^n = R^n(2 + 2^n)
   \]
   Substituting $a = R\sqrt{3}$:
   \[
   2(R\sqrt{3})^n = R^n(2 + 2^n)
   \]
   Simplifying:
   \[
   2R^n 3^{n/2} = R^n (2 + 2^n)
   \]
   Dividing both sides by $R^n$:
   \[
   2 \cdot 3^{n/2} = 2 + 2^n
   \]
   Dividing both sides by 2:
   \[
   3^{n/2} = 1 + 2^{n-1}
   \]

5. **Solve the equation $3^{n/2} = 1 + 2^{n-1}$:**
   - For $n = 2$:
     \[
     3^{2/2} = 1 + 2^{2-1} \implies 3 = 1 + 2 = 3 \quad \text{(True)}
     \]
   - For $n = 4$:
     \[
     3^{4/2} = 1 + 2^{4-1} \implies 9 = 1 + 8 = 9 \quad \text{(True)}
     \]
   - For other values of $n$, the equation does not hold true.

6. **Verify $n = 2$ and $n = 4$ using geometric properties:**
   - For $n = 2$, we use the identity:
     \[
     MA^2 + MB^2 + MC^2 = 2(MB^2 + MC^2 + MB \cdot MC)
     \]
     Using trigonometric identities and the fact that $M$ lies on the circumcircle, we can show that $f(M)$ is constant.

   - For $n = 4$, we use barycentric coordinates and the identity:
     \[
     S_A^2 + S_B^2 + S_C^2 = S^2
     \]
     where $S_A, S_B, S_C$ are the areas of sub-triangles formed with $M$ and $S$ is the area of $\triangle ABC$. This shows that $f(M)$ is constant.

Conclusion:
\[
\boxed{n = 2, 4}
\]