Answer
$a_n=3n-11$
Work Step by Step
We know that the general formula of an arithmetic sequence is given by
$a_n= a_1+(n-1) d$ ...(1)
Here, we have $d=3$; $a_3=-2; a_{17}=40$
$a_{17}=a_3+(17-3)d$
Now, we have $a_n=a_3+(n-3)d$
This gives: $a_n=-2+(n-3)3=-2+3n-9$
Hence, our answer is $a_n=3n-11$