vault backup: 2023-09-25 13:31:57

This commit is contained in:
2023-09-25 13:31:57 +02:00
parent 4ba446d7d6
commit 4d30f6a9c6
2 changed files with 22 additions and 9 deletions

View File

@ -382,5 +382,18 @@ let rec puissance_better x n =
let pb = puissance_better x (n/2) in pb*pb
else
let pb_odd = puissance_better x (n/2) * n in pb_odd*pb_odd;;
(*Correction*)
let power x n = match n with
| 0 -> (match x with
| 0. -> failwith "power 0^0 impossible"
| _ -> 1.)
| _ -> (match x with
| 1. -> 1.
| 0. -> 0.
| -1. -> if n mod 2 = 0 then 1. else -1.)
| _ -> (let rec p = function
| 0 -> 1.
| n -> x*.p(n-1) in p n)
;;
```