Ask Your Question
0

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

asked 2015-03-09 14:45:56 +0100

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-25 01:34:04 +0100

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 15:45:01 +0100 )edit
0

answered 2015-03-09 15:03:12 +0100

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 15:24:36 +0100 )edit

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

kcrisman gravatar imagekcrisman ( 2015-03-10 00:05:51 +0100 )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 14:45:56 +0100

Seen: 475 times

Last updated: May 25 '17