Verify the truth of Fermat's Little Theorem (either variant) using the composite number 391=17⋅23 as the choice of the base (either a or b), and for p assuming the value of every prime number between 100 and 1000.
Build up a solution slowly --- make a list of powers (start with just a few primes), then make a list of powers reduced by modular arithmetic, then a list of comparisons with the predicted value, then a check on all these logical values resulting from the comparisons. Eventually you will write a single line that performs the verification by eventually printing out True.