We should find the last digit of this number. It cannot be even or equal to 5.
Number 1017+1 is divisible by 11.
Consider number 1017+9 modulo 7. Then, 10≡3(mod7)⇒102≡2(mod7)⇒103≡−1(mod7)⇒1015≡−1(mod7)⇒1017≡−2(mod7)⇒1017+9≡0(mod7).
Consider number 1017+7 modulo 17. 10≡10(mod17)⇒102≡−2(mod17)⇒108≡16≡−1(mod17)⇒1016≡1(mod17)⇒1017≡10(mod17)⇒1017+7≡0(mod17).
Thus, the only candidate for a prime number left is 1017+3, and since it is given that such a number exists, this must be it.