next up previous contents index
suivant: GCD in /p[x] : monter: Computing in /p or précédent: Inverse in /p :   Table des matières   Index


Rebuild a fraction from it's value modulo p : fracmod

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

- $\displaystyle {\frac{{\sqrt{p}}}{{2}}}$ < a $\displaystyle \leq$ $\displaystyle {\frac{{\sqrt{p}}}{{2}}}$,    0 $\displaystyle \leq$ b < $\displaystyle {\frac{{\sqrt{p}}}{{2}}}$,    n×b = a(mod p)

In other words n = a/b(mod p).
Input :
fracmod(3,13)
Output :
-1/4
Indeed : 3* -4 = - 12 = 1 ( mod 13), hence 3 = - 1/4%13.
Input :
fracmod(13,121)
Output :
-4/9
Indeed : 13× -9 = - 117 = 4 ( mod 121) hence 13 = - 4/9%13.



giac documentation written by Renée De Graeve and Bernard Parisse