Fermat's theorem steps

https://online.codingblocks.com/app/player/196926/content/186100/8099/lecture

here a^(n-1)%n=1

and if n is odd we have (n-1) as even

  • n-1= d * 2^s

where d is odd

a^(d * 2^s) %n =1 is understood .

But how did we proceed further to get :

a^d %n =1

hello @bishal_c
is this what u want to know ->
we know x^(p-1) mod p => 1 if p is prime number…fermant little theorem

now to calculate (a^b) mod p .
we can write b = (p-1) + (p-1) + (p-1) … + k

where k is remainder we are left with. i.e k=b%(p-1)

substituting value of b
(a^b)mod p = a^(p-1 + p-1 + p-1 + p-1 … + k) mod p

now using property a^(x+y) => a^x * a^y

=> ( a^(p-1) * a^(p-1) * a^(p-1) … a^k )mod p

now we know a^(p-1) mod p =1

=> 1 * 1 * 1 …a^k mod p
=> a^k mod p
substituting value of k
=> a^(b%(p-1) ) mod p

Thank you for replying …

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.