Jump to content

Lucas-Carmichael numbers: Difference between revisions

m
→‎{{header|Python}}: use the built-in `pow(b,-1,m)` for computing the modular inverse (faster)
m (→‎{{header|Python}}: minor optimization)
m (→‎{{header|Python}}: use the built-in `pow(b,-1,m)` for computing the modular inverse (faster))
Line 500:
Uses the [[wp:SymPy|SymPy]] library.
<syntaxhighlight lang="python">from sympy.ntheory import sieve, isprime, prime
from sympy.core import mod_inverse, integer_nthroot
from math import lcm, gcd, isqrt
 
Line 513:
hi = min(B // m + 1, max_p)
 
u = l - mod_inversepow(m, -1, l)
while u < lo: u += l
if u > hi: return
2,756

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.