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

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

edit retag close merge delete

Sort by ยป oldest newest most voted

How can I add the negative divisors?

more

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

sage: a = ZZ(2019)
[1, 3, 673, 2019]
sage: anegdiv = [ -d for d in adiv ]
sage: anegdiv
[-1, -3, -673, -2019]
[1, 3, 673, 2019, -1, -3, -673, -2019]
[-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.

( 2017-05-25 15:45:01 +0200 )edit

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]
more

1

Super bedankt!

( 2015-03-09 15:24:36 +0200 )edit

Keep in mind that these are the positive divisors...

( 2015-03-10 00:05:51 +0200 )edit