More generally, for $\rm\!\ c\in R\!\ $ any ring, every $\rm\!\ r\ne 0\,$ may be written uniquely in the form $\rm\!\ r = c^n\,\! b,\,$ where $\rm\,c\nmid b,\,$ assuming $\rm\,c\,$ is cancellable, and only $0\,$ is divisible by arbitrarily high powers of $\rm\,c.\,$ Proof $ $ by hypothesis there exists a largest natural $\rm\,n\,$ such that $\rm\,c^n\,|\,r,\,$ hence $\rm\,r = c^n\, b,\ c\nmid b.\,$ Suppose $\rm\,r = c^k\:\! d,\ c\nmid d.\,$ If $\rm\,k < n,\,$ then cancelling $\rm\,c^k\,$ in $\rm\,c^n\:\! b = c^k\:\!d\,$ yields $\rm\,c^{n-k}\:\!b = d,\,$ so $\rm\,c\,|\,d,\,$ contra hypothesis. Thus $\rm\,k = n,\,$ so cancelling $\rm\,c^k\,$ yields $\rm\,b = d,\,$ thus uniqueness. $\bf\small QED$
Your special case follows by applying the above to the cancellable element $\, {\rm c} = x-r\in R[x],\,$ which clearly satisfies the bounded divisibility hypothesis: $\,(x\!-\!r)^n\,|\,f\ne0\,\Rightarrow\, n\le \deg\ f.$