Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let brent f x0 =
- let rec affiche_suite x = function
- | 0 -> ()
- | n -> Printf.printf "%d " x; affiche_suite (f x) (n-1)
- in
- let rec brent' xh h =
- let rec parcours_k xk k=
- if xk = xh then (Printf.printf "xh = xk pour h=%d, k=%d, xh = xk = %d\n" h k xk; (k, xk))
- else if k >= 2*h+1 then (Printf.printf "k : [%d, %d] termine.\n" (h+1) (2*h+1); (k, xk))
- else parcours_k (f xk) (k+1)
- in
- let k, xk = parcours_k (f xh) (h+1) in
- if xk = xh then (h, k)
- else brent' xk k
- in
- let h, k = brent' x0 0 in
- affiche_suite x0 (k+1); (h, k, k-h)
- ;;
- let n = 1589;;
- let f x = (x*x+1) mod n;;
- brent f 0;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement