Message Boards Message Boards

0
|
6082 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Computing 0^0 mod 7 with Mod and PowerMod

Posted 9 years ago

I would like to know why Mod gives the correct result and PowerMod gives an incorrect result.

Mod[0^0,7]
PowerMod[0,0,7]
POSTED BY: Rodrigo Sambade
3 Replies

Yes, 0 is not positive, but does that explain the result of PowerMod[0, 0, 7]?

The reason is that 0 and 7 are congruent modulo 7, so in the context of the ring Z/7Z, 0^0 can be thought of as the same as 7^0. Thus we obtain the same result as PowerMod[7, 0, 7].

With Mod the situation is different, since 0^0 evaluates to Indeterminate first, so we are asking for Mod[Indeterminate, 7].

POSTED BY: Ilian Gachevski

I think that is indeed the real reason, i was trying to point out that 0 is one of those `fringe' cases where things might be different from what you expect...

POSTED BY: Sander Huisman

Maybe it has something to do with the following in the help:

For positive b, PowerMod[a,b,m] gives the same result as Mod[a^b, m] but is much more efficient.

0 is not positive:

Positive[0]
False
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract