Ticket #13639 (closed defect: fixed)
Inverting 0 mod 1
| Reported by: | jdemeyer | Owned by: | AlexGhitza |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-5.5 |
| Component: | basic arithmetic | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | Robert Bradshaw |
| Authors: | Jeroen Demeyer | Merged in: | sage-5.5.beta1 |
| Dependencies: | Stopgaps: |
Description
sage: ~Mod(0,1) --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) /usr/local/src/sage-5.4.rc1/<ipython console> in <module>() /usr/local/src/sage-5.4.rc1/local/lib/python2.7/site-packages/sage/rings/finite_rings/integer_mod.so in sage.rings.finite_rings.integer_mod.IntegerMod_int.__invert__ (sage/rings/finite_rings/integer_mod.c:22320)() ZeroDivisionError: Inverse does not exist.
But modulo 1, the inverse does exist. Note that gcd(0,1) == 1.
Attachments
Change History
comment:2 follow-up: ↓ 4 Changed 7 months ago by robertwb
- Status changed from needs_review to positive_review
Looks good to me, nice cleanup too. How did you run into this?
comment:4 in reply to: ↑ 2 Changed 7 months ago by jdemeyer
Replying to robertwb:
How did you run into this?
Quite naturally in fact. I needed some random numbers to create an exercise for students to solve which involved (amonst other things) inverting Mod(r,s). I wrote a loop to randomly generate some numbers, checking that gcd(r,s) == 1.
Note: See
TracTickets for help on using
tickets.

