Yes, that is Fermat's little theorem. It states that for any prime and any integer , .
This (in the form you have written) is not valid for every integer only when and are coprime (in which case it is also valid for However, if you re-write it as then it is valid for every integer (including 1).
It is more usual to write the prime as Thus Fermat’s little theorem is usually presented as (which is valid if or (which is valid for any integer