| modlog | R Documentation | 
Realizes the modular (or discrete) logarithm modulo a prime number
p, that is determines the unique exponent n such that
g^n = x \, \mathrm{mod} \, p, g a primitive root.
modlog(g, x, p)
| g | a primitive root mod p. | 
| x | an integer. | 
| p | prime number. | 
The method is in principle a complete search, cut short by "Shank's 
trick", the giantstep-babystep approach, see Forster
(1996, pp. 65f). g has to be a primitive root modulo p,
otherwise exponentiation is not bijective.
Returns an integer.
Forster, O. (1996). Algorithmische Zahlentheorie. Friedr. Vieweg u. Sohn Verlagsgesellschaft mbH, Wiesbaden.
primroot
modlog(11, 998, 1009) # 505 , i.e., 11^505 = 998 mod 1009
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.