The Fast Trick To Test If N Is Prime With Python Code Aks Primality Testing In Polylog N Time

Original video youtu.be/HvIh1Ngah0A

Python NumPy Sample Code is here colab.research.google.com/drive/1MJbvssjMHserGoWcbju8u8aJLC1wvBYa?usp=sharing .

Wiki page on AKS Primality testing en.m.wikipedia.org/wiki/AKS_primality_test

Chapters (Powered by ChapterMe) -
00:00 - Pascal's Triangle Rabbit Hole
00:10 - Follow Up From Main Pascal's Triangle Video
01:36 - Annals of Mathematics Paper PRIMES is in P
02:30 - (X+1)^n = X^n+1 mod n is the same as 0s in Pascals Triangle
04:35 - Python Implementation of Pascal's Triangle
05:18 - Plot rows, test primes, generate faster
05:42 - Example Test if n=91 is Prime
06:30 - Faster way to generate the n-th row using log(n) convolutions
09:48 - is_prime_Pascal(28657) Generate nth row up to sqrt(n) and check zeros
11:26 - Algorithm is still O(sqrt(n)) which is too slow
12:49 - The genius idea of the paper: Reduce from n to r
15:08 - Mod X^r- 1 is the same as stacking numbers on top of each other to satisfy equation
18:08 - Simple Python implementation
19:47 - Full algorithm from paper Which r and a values need to be checked

  • The FAST trick to test if n is prime (with Python code) | AKS Primality Testing in poly(log n) time ( Download)
  • Fermat's primality test ( Download)