Ask Your Question
1

Using powermod in a loop

asked 2018-09-13 14:16:32 +0200

jds9973 gravatar image

Sorry if this question is naive, I have just started using Sage. I was playing around with Carmichael numbers and wanted to produce a list of a^n mod n for various values of a.

I thought the code for k in range(2,5): j = k.powermod(n,n)

would do what I wanted. But I get the error message 'int' object has no attribute 'powermod'

Any suggestions?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2018-09-13 14:54:35 +0200

tmonteil gravatar image

The problem is that range produces Python int, not Sage integers, hence the powermod method is not avaiable. Just replace range with srange and it shoud work !

edit flag offensive delete link more
0

answered 2018-09-14 02:04:13 +0200

slelievre gravatar image

Using pow(a, b, c) instead of a.powermod(b, c) should work.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2018-09-13 14:16:32 +0200

Seen: 369 times

Last updated: Sep 14 '18