Opened 7 years ago
Closed 7 years ago
#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: | Merged in: | sage-5.5.beta1 | |
Authors: | Jeroen Demeyer | Reviewers: | Robert Bradshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
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 (1)
Change History (6)
Changed 7 years ago by
comment:1 Changed 7 years ago by
- Status changed from new to needs_review
comment:2 follow-up: ↓ 4 Changed 7 years ago by
- Status changed from needs_review to positive_review
comment:3 Changed 7 years ago by
- Reviewers set to Robert Bradshaw
comment:4 in reply to: ↑ 2 Changed 7 years ago by
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
.
comment:5 Changed 7 years ago by
- Merged in set to sage-5.5.beta1
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
Looks good to me, nice cleanup too. How did you run into this?