fracmod takes two arguments, an integer n
(representing a fraction) and an integer p (the modulus).
If possible, fracmod returns a fraction a/b such that
− |
| < a ≤ |
| , 0 ≤ b < |
| , n × b =a (mod p ) |
In other words n=a/b(mod p ).
Input :
Output :
Indeed : 3*−4=−12=1 (mod 13), hence 3=−1/4%13.
Input :
Output :
Indeed : 13×−9=−117=4 (mod 121) hence 13=−4/9%13.