Tonelli-Shanks algorithm: Difference between revisions

m
(add PicoLisp)
Line 971:
(de ts (N P)
(and
(= 1 (legendre N P))
(let
(Q (dec P)
Line 997:
D (**Mod N Q P)
M S )
(loopuntil (=1 D)
(T (=1 D) (list R (- P R)))
(zero I)
(for
Line 1,016 ⟶ 1,015:
C (% (* B B) P)
D (% (* D C) P)
M I ) ) ) ) ) )
(T (=1 D) (list R (- P R)) ) ) ) )
 
 
(println (ts 10 13))
298

edits