galois.totatives

galois.totatives(n)

Returns the positive integers (totatives) in \(1 \le k < n\) that are coprime with \(n\), i.e. \(gcd(n, k) = 1\).

The totatives of \(n\) form the multiplicative group \(\mathbb{Z}{_n^\times}\).

Parameters

n (int) – A positive integer.

Returns

The totatives of \(n\).

Return type

list

References

Examples

In [526]: n = 20

In [527]: totatives = galois.totatives(n); totatives
Out[527]: [1, 3, 7, 9, 11, 13, 17, 19]

In [528]: phi = galois.euler_totient(n); phi
Out[528]: 8

In [529]: len(totatives) == phi
Out[529]: True