Can you provide a proof or a counterexample for the claim given below ? 

Inspired by Agrawal's conjecture in [this paper][1] and by Theorem 4 in [this paper][2] I have formulated the following claim :

> Let $n$ be a natural number greater than two . Let $r$ be the smallest odd prime number such that $r \nmid n$ and $n^2 \not\equiv 1 \pmod r$ . Let $T_n(x)$ be Chebyshev polynomial of the first kind , then $n$ is a prime number if and only if $T_n(x) \equiv x^n \pmod {x^r-1,n}$ .

You can run this test [here][3] .

I have tested this claim up to $5 \cdot 10^4$ and there were no counterexamples .


  [1]: https://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf
  [2]: http://icm.mcs.kent.edu/reports/1999/chebpol.pdf
  [3]: https://sagecell.sagemath.org/?z=eJw9jU0KgzAQhfeF3iEIhRkaoalLyRF6BRe1kQTiJIyhjeDhHYS6Gd58vB-ynemvF7ad3J8P0cErfYA0o7UPtW0qhqmcbHgKNkqzJVdL5jA74LtBlHSYDhvkFEfv3uvi3VdCRlfEG9SBW4OasAXRdBJUsqOliQo0R2GD_3dMc05LKIKw3wGYCjLD&lang=gp