Karl-Dieter Crisman's Number Theory: In Context and Interactive is a free textbook for an upper-level (US) number theory course, with a clear vision to expose students to the connections to all areas of mathematics. There are many exercises, both proof-based and computational, and nearly every concept can be visualized or experimented with using the open source mathematics software SageMath.

The book tackles all standard topics of modular arithmetic, congruences, and prime numbers, including quadratic reciprocity. In addition, there is significant coverage of various cryptographic issues, geometric connections, arithmetic functions, and basic analytic number theory, ending with a beginner's introduction to the Riemann Hypothesis. Ordinarily this should be enough material for a semester course with no prerequisites other than a proof-transition experience and vaguely remembering some calculus.

The current edition is the January 2020, or 2020/1 Edition. This addressed the switch in the Sage cell server to using SageMath 9.0, which runs on Python 3. Most Sage commands should still work on older versions of Sage; see below for other editions.

The immediately preceding August 2019, or 2019/8 Edition, addressed all known typos/unclear pronouns, clarified many proofs, added much more cross-referencing and index entries, and to my knowledge fixed all of the few known actual errata. Other than fixing Sage commands, this edition is identical to the current one.

Those desiring access to the previous edition from January 2017 may find it here. See also the errata from the previous edition.