Disarium numbers: Difference between revisions

OCaml: faster exponentiation
(add OCaml)
(OCaml: faster exponentiation)
Line 1,295:
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let(* powspeed-optimized xexponentiation; =doesn't support exponents < 2 *)
let rec aux accpow b n = function
if n |land 1 ->= acc * b0
then if n = 2 then b * b else pow (b * b) (n lsr 1)
| 0 -> acc
else if |n y= ->3 auxthen (ifb y* landb 1* = 0 then accb else accb * b)pow (b * b) (yn lsr 1)
in
aux 1 x
 
let is_disarium n =
559

edits