let estpair a = if a land 1 =1 then false else true;;
(*version naive*)
let rec exp a b =
if b=0
then 1
else if estpair b
then exp (a*a) (b lsr 1)
else a * (exp a (b-1) );;
(* ou en tail rec *)
let exp a b =
let rec f acc a b =
if b=0
then acc
else if estpair b
then f acc (a*a) (b lsr 1)
else f (acc * a) a (b-1)
in f 1 a b;;