Number Theory
Sage has extensive functionality for number theory. For example, we can do arithmetic in as follows:
Sage contains standard number theoretic functions. For example,
Perfect!
Sage’s "sigma(n,k)" function adds up the powers of the divisors of "n":
We next illustrate the extended Euclidean algorithm, Euler’s -function, and the Chinese remainder theorem:
We next verify something about the problem.
Finally we illustrate the Chinese remainder theorem.
-adic Numbers
The field of -adic numbers is implemented in Sage. Note that once a -adic field is created, you cannot change its precision.
Much work has been done implementing rings of integers in -adic fields and number fields. The interested reader is invited to read sage.rings.padics.tutorial and ask the experts on the "sage-support" Google group for further details.
A number of related methods are already implemented in the NumberField class.