September 2014
Intermediate to advanced
512 pages
12h 39m
English
SymPy contains many number-theory-related routines: obtaining prime numbers, integer decompositions, and much more. We will show a few examples here.
To display legends using LaTeX in matplotlib, you will need an installation of LaTeX on your computer (see this chapter's Introduction).
In [1]: from sympy import *
init_printing()
In [2]: import sympy.ntheory as ntIn [3]: nt.isprime(2011) Out[3]: True
In [4]: nt.nextprime(2011) Out[4]: 2017
In [5]: nt.prime(1000) Out[5]: 7919
In [6]: nt.primepi(2011) ...
Read now
Unlock full access