In the given case, since the given polynomial is of the fifth degree, you only have to try S=1,2,3,4 and up to 5.

In fact:

Let's factor the polynomial

f(x)=n^5-17*n^3+16*n

=(n-4)*(n-1)*n*(n+1)*(n+4)

From this you will find the factors have the following properties:

if

n=0 (mod 4)

then

n=0 (mod 4) ... hypothesis

n-4=0 (mod 4)

n-1=3 (mod 4)

n+1=1 (mod 4)

n+2=2 (mod 4) since n=0 (mod 4)

Which means that if S=4, then

f(n) = 0 for all n≥4 since the factors have residues 0,1,2,3 when divided by 4.