Positive Integers¶
- class sage.sets.positive_integers.PositiveIntegers[source]¶
Bases:
IntegerRangeInfinite
The enumerated set of positive integers. To fix the ideas, we mean \(\{1, 2, 3, 4, 5, \dots \}\).
This class implements the set of positive integers, as an enumerated set (see
InfiniteEnumeratedSets
).This set is an integer range set. The construction is therefore done by IntegerRange (see
IntegerRange
).EXAMPLES:
sage: PP = PositiveIntegers() sage: PP Positive integers sage: PP.cardinality() +Infinity sage: TestSuite(PP).run() sage: PP.list() Traceback (most recent call last): ... NotImplementedError: cannot list an infinite set sage: it = iter(PP) sage: (next(it), next(it), next(it), next(it), next(it)) (1, 2, 3, 4, 5) sage: PP.first() 1
>>> from sage.all import * >>> PP = PositiveIntegers() >>> PP Positive integers >>> PP.cardinality() +Infinity >>> TestSuite(PP).run() >>> PP.list() Traceback (most recent call last): ... NotImplementedError: cannot list an infinite set >>> it = iter(PP) >>> (next(it), next(it), next(it), next(it), next(it)) (1, 2, 3, 4, 5) >>> PP.first() 1