Ask Your Question
0

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

asked 2015-03-09 08:45:56 -0500

Annete gravatar image

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

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-05-24 18:34:04 -0500

Mathematic gravatar image

How can I add the negative divisors?

edit flag offensive delete link more

Comments

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.

dan_fulea gravatar imagedan_fulea ( 2017-05-25 08:45:01 -0500 )edit
0

answered 2015-03-09 09:03:12 -0500

tmonteil gravatar image

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]
edit flag offensive delete link more

Comments

1

Super bedankt!

Annete gravatar imageAnnete ( 2015-03-09 09:24:36 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2015-03-09 18:05:51 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 121 times

Last updated: May 24