# list of divisors(p-1),pi s prime

How to compute with sage? list of divisors(p-1),

add a comment

list of divisors(p-1),pi s prime

How to compute with sage? list of divisors(p-1),

add a comment

0

How can I add the negative divisors?

The answer to the answer as a comment this time, sample code:

```
sage: a = ZZ(2019)
sage: adiv = a.divisors()
sage: adiv
[1, 3, 673, 2019]
sage: anegdiv = [ -d for d in adiv ]
sage: anegdiv
[-1, -3, -673, -2019]
sage: adiv + anegdiv
[1, 3, 673, 2019, -1, -3, -673, -2019]
sage: anegdiv + adiv
[-1, -3, -673, -2019, 1, 3, 673, 2019]
sage: [ d*sig for d in a.divisors() for sig in [-1,1] ]
[-1, 1, -3, 3, -673, 673, -2019, 2019]
sage: [ d*sig for sig in [-1,1] for d in a.divisors() ]
[-1, -3, -673, -2019, 1, 3, 673, 2019]
```

Of course, the structural code is not optimal, and the optimal code is not beautiful.

0

Given a Python/Sage objects, you can get available methods, with tab-completion, so if you do:

```
sage: p = 13
sage: a = p-1
sage: a.<TAB>
```

you will see all the methods that can be applied to `a`

, in particular:

```
sage: a.divisors()
[1, 2, 3, 4, 6, 12]
```

Asked: **
2015-03-09 08:45:56 -0500
**

Seen: **126 times**

Last updated: **May 24 '17**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.