Found in 1 comment on Hacker News
phkahler · 2021-09-20 · Original thread
I found the following book to be great introduction: https://www.amazon.com/Factorization-Primality-Testing-Under...

It focuses on factoring and primality testing, but it also covers a lot of introductory number theory. IIRC it also covers continued fractions as used for factoring and the quadratic sieve and MPQS. The pseudo-code given in the book is very easy to translate into python, which supports large integers and efficient exponentiation mod P.