Finding a square root of -1 mod p
Explains how to compute a square root of -1 modulo a prime p, using number theory and Python code examples.
Explains how to compute a square root of -1 modulo a prime p, using number theory and Python code examples.
Explores Fermat's theorem on expressing primes as sums of two squares, comparing Gauss's formula with a more efficient computational algorithm.
Explains Montgomery's trick for efficiently computing multiple modular inverses at once, with Python code examples and performance comparison.
Explains the math and Python code for perfect in-shuffles and out-shuffles, comparing how many shuffles restore a deck's order.