Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 494 Bytes

fermats-little-theorem.md

File metadata and controls

19 lines (14 loc) · 494 Bytes

← Return to Index

Fermat's Little Theorem

  • If p is a prime, then for any integer 1 < a < p, ap-1-1 is an integer multiple of p
    • ap-1-1 mod p = 0
  • This, we can guarantee that N is composite if aN-1-1 mod N ≠ 0
  • However, if it = 0, we cannot guarantee that N is prime

Pseudocode

repeat k times:
	a = any random number between 2 and N-1
		if a^(N-1) mod N != 0:
			return False
return Maybe