let curry f = function a-> (function b -> f (a,b));; let decurry f = function (a,b) -> f a b;; let u n = let u0 = ref 1.0 in for i = 0 to n do u0 := sin !u0 done; !u0 ;; let u = ref 1. and n = ref 0 in while !u > 0.0001 do u := sin !u; n := !n + 1 done; !n;; let factoriter n = let k = ref 1 in for i = 2 to n do k := !k * i done; !k;; let puissance x n = let p = ref 1 in for i = 1 to n do p := !p * x done; !p;; let sum m n = let s = ref 0. and c = ref 0. in for i = m to n do c := !c +. 1.; if i >= m then s := !s +. 1. /. !c done; !s ;; let pgcd a b = let c = ref a and d = ref b and e = ref 0 in while !c mod !d <> 0 do e := !c; c := !d; d := !e mod !d done; !d;; let valuation p n = let v = ref 0 and aux = ref n in while !aux mod p = 0 do v := !v +1; aux := !aux / p done; !v;; let maximum a = let max = ref a.(0) in for i = 0 to Array.length(a)-1 do if a.(i) > !max then max := a.(i) done; !max;; let mirroir t = let n = Array.length t in let u = Array.make n t.(0) in for i = 0 to n-1 do u.(i) <- t.(n-1-i) done; u;; let appartenance t x= let a = ref 0 and b = ref false in while t.(!a) <> x && !a< Array.length t do a := !a +1; done; if !a > 0 then b := true; !b ;; let appartprof t x = let n = Array.length t and i = ref 0 in while !i t.(!i) do i := !i+1 done; !i t.(!i) do i := !i+1 done; (!i<(n-1) )||(x=aux );; let permut t = let n = Array.length t in let b = ref true in for i = 0 to n-1 do if t.(i)>=n || t.(0)<0 then b := false; for j=i+1 to n-1 do if t.(i)=t.(j) then b := false done; done; !b;; let f x = x*x;; let u u0 n = let un = ref u0 in for k= 0 to n do un := f !un done; !un;; let rec suite_rec u0 n = if n= 0 then u0 else f (suite_rec u0 (n-1));; let factoiter n = let u = ref 1 in for k=1 to n do u := !u * k done; !u;; let rec factorecu n = match n with | 0 -> 1 | _ -> n*factorecu (n-1);; let rec puissancerecu a n = match n with | 0 -> 1 | _ -> a* puissancerecu a (n-1);; let puissanceiter a n = let b = ref 1 in for k=1 to n do b := !b * a done; !b;; let rec carrerecu b = match b with | 0 -> 0 | _ -> carrerecu (b-1) + 2*b -1 let rec sumpq p q = match q with | 0 -> p | _ -> sumpq (p+1) (q-1);; let rec productpq p q = match q with | 0 -> 0 | _-> (productpq p (q-1))+q;; let rec minimumtab t = let n = Array.length t in if n=1 then t.(0) else let m = minimumtab (Array.sub t 1 (n-1)) in if t.(0) (i,o) | i when t.(i)>t.(o) -> (m,i) | _ -> (m,o);; let minmax t = minmax_aux t 0;; let rec productegypt p q = match q with | 0 -> 0 | q when q mod 2 = 0 -> productegypt (2*p) (q/2) | _ ->p+ productegypt p (q-1);; let rec divisioneucli1 a b = if a a | (a,b) when a pgcd2prof b a | _ -> pgcd2prof (a-b) b;; let rec fib n = if n <= 0 then 0. else if n = 1 then 1. else fib (n-1) +. fib (n-2);; let rec coeffbinom n p = match (p,n) with | (0,n) -> 1 | (p,n) when p = n-> 1 | _ -> (coeffbinom (n-1) p) + (coeffbinom (n-1) (p-1));; let rec coeffbinom2duprof p n = match (p,n) with | (0,n) -> 1 | _ -> (n* coeffbinom2duprof (p-1) (n-1))/(p);;