rashida564 said:
Is it try and error method?
Where did you see try and error? Factorization to investigate factors is a quite natural thing.
##a^6\equiv a \operatorname{mod} 6 ## is defined as ##6\,|\,a^6-a##, so factoring the polynomial ##a^6-a## is the next thing to do. After that, it becomes clear that ##2\,|\,a^6-6## in any case, as ##a(a-1)\,|\,a^6-a##. So, we are left with what
@Infrared has said, the divisor ##3##. We have that ##3## divides ##a(a-1)## iff ##3\,|\,a \Longleftrightarrow a\equiv 0 \operatorname{mod} 3## or ##3\,|\,(a-1) \Longleftrightarrow a\equiv 1\operatorname{mod} 3## because ##3## is prime. Thus we are left with all numbers ##a \equiv 2 \operatorname{mod} 3##, i.e. ##a=3n+2## and ##6\,|\,a^6-a \Longleftrightarrow 3\,|\,a^4+a^3+a^2+a+1## for those numbers. However, if ##a=3n+2## it is easy to see, that ##a^4+a^3+a^2+a+1 =3m+2## which is never divisible by ##3##.