# Revision history [back]

### Easiest way to work in the multiplicative group of Zmod(n)

Given an integer $n$, one can define in SageMath the additive group $\mathbb Z/n\mathbb Z$ by

sage: Zn = Zmod(n) # or Integers(n)

Now, I would like to work in the multiplicative group $(\mathbb Z/n\mathbb Z)^*$. Of course, I can write

sage: G = [a for a in Zn if gcd(a,n) == 1]

What I would like is an easier way of writing such a thing, such as:

sage: G = Zn.multiplicative_group() #does not exist!

And then, I could for instance write something like:

### Easiest way to work in the multiplicative group of Zmod(n)

Given an integer $n$, one can define in SageMath the additive group $\mathbb Z/n\mathbb Z$ by

sage: Zn = Zmod(n) # or Integers(n)

Now, I would like to work in the multiplicative group $(\mathbb Z/n\mathbb Z)^*$. Of course, I can write

sage: G = [a for a in Zn if gcd(a,n) == 1]
sage: Zn(4).multiplicative_order()
6

What I would like is an easier way of writing such a thing, such as:

sage: G = Zn.multiplicative_group() #does # does not exist!
sage: G(4).order()
6

And then, I could for instance write Does there exist something like:in SageMath to perform such kind of computations?

 3 retagged FrédéricC 4189 ●3 ●37 ●85

### Easiest way to work in the multiplicative group of Zmod(n)

Given an integer $n$, one can define in SageMath the additive group $\mathbb Z/n\mathbb Z$ by

sage: Zn = Zmod(n) # or Integers(n)

Now, I would like to work in the multiplicative group $(\mathbb Z/n\mathbb Z)^*$. Of course, I can write

sage: G = [a for a in Zn if gcd(a,n) == 1]
sage: Zn(4).multiplicative_order()
6

What I would like is an easier way of writing such a thing, such as:

sage: G = Zn.multiplicative_group() # does not exist!
sage: G(4).order()
6

Does there exist something in SageMath to perform such kind of computations?

 4 retagged tmonteil 24778 ●29 ●176 ●461 http://wiki.sagemath.o...

### Easiest way to work in the multiplicative group of Zmod(n)

Given an integer $n$, one can define in SageMath the additive group $\mathbb Z/n\mathbb Z$ by

sage: Zn = Zmod(n) # or Integers(n)

Now, I would like to work in the multiplicative group $(\mathbb Z/n\mathbb Z)^*$. Of course, I can write

sage: G = [a for a in Zn if gcd(a,n) == 1]
sage: Zn(4).multiplicative_order()
6

What I would like is an easier way of writing such a thing, such as:

sage: G = Zn.multiplicative_group() # does not exist!
sage: G(4).order()
6

Does there exist something in SageMath to perform such kind of computations?