vault backup: 2023-09-25 13:31:57
This commit is contained in:
@ -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)
|
||||
;;
|
||||
```
|
Reference in New Issue
Block a user