Xét :
+) \(n=3k\left(k\in N\right)\)
Ta có: \(M=2017^{3k}+2017.3k+\left(3k\right)^{2017}⋮3\)
<=> \(2017^{3k}⋮3\)vô lí vì \(2017:3\)dư 1 nên \(2017^{3k}:3\)dư 1
+) \(n=3k+1\left(k\in N\right)\)
Ta có: \(M=2017^{3k+1}+2017.\left(3k+1\right)+\left(3k+1\right)^{2017}\equiv1+1+1\equiv0\left(mod3\right)\)
=> \(M⋮3\)
+) \(n=3k+2\left(k\in N\right)\)
Ta có: \(M=2017^{3k+2}+2017.\left(3k+2\right)+\left(3k+2\right)^{2017}\equiv1+2+2^{2017}\equiv1+2+\left(-1\right)^{2017}\equiv2\left(mod3\right)\)
=> \(M⋮̸3\)
Vậy n = 3k +1 ( k là số tự nhiên ) thì M chia hết cho 3.