Notice that
∣f(x)−f(y)∣≤∣x−y∣n⟹∣x−y∣∣f(x)−f(y)∣≤∣x−y∣n−1⟹x−yf(x)−f(y)≤∣x−y∣n−1⟹−∣x−y∣n−1≤x−yf(x)−f(y)≤∣x−y∣n−1.By the squeeze theorem, since for any y we have
x→ylim−∣x−y∣n−1=x→ylim∣x−y∣n−1=0,then
f′(y)=x→ylimx−yf(x)−f(y)=0.Therefore, f is constant.