In [1]:
p = Primes()
In [2]:
p
Out[2]:
Set of all prime numbers: 2, 3, 5, 7, ...
In [3]:
type(p)
Out[3]:
<class 'sage.sets.primes.Primes_with_category'>
In [4]:
321 in p
Out[4]:
False
In [5]:
199 in p
Out[5]:
True
In [6]:
p.first()
Out[6]:
2
In [9]:
p.next(5)
Out[9]:
7
In [10]:
p.next(199)
Out[10]:
211
In [11]:
p[:20]
Out[11]:
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]