vault backup: 2023-09-25 13:35:25
This commit is contained in:
parent
4d30f6a9c6
commit
58d77a9418
@ -383,7 +383,7 @@ let rec puissance_better x n =
|
|||||||
else
|
else
|
||||||
let pb_odd = puissance_better x (n/2) * n in pb_odd*pb_odd;;
|
let pb_odd = puissance_better x (n/2) * n in pb_odd*pb_odd;;
|
||||||
|
|
||||||
(*Correction*)
|
(*Correction v1*)
|
||||||
let power x n = match n with
|
let power x n = match n with
|
||||||
| 0 -> (match x with
|
| 0 -> (match x with
|
||||||
| 0. -> failwith "power 0^0 impossible"
|
| 0. -> failwith "power 0^0 impossible"
|
||||||
@ -395,5 +395,19 @@ let power x n = match n with
|
|||||||
| _ -> (let rec p = function
|
| _ -> (let rec p = function
|
||||||
| 0 -> 1.
|
| 0 -> 1.
|
||||||
| n -> x*.p(n-1) in p n)
|
| n -> x*.p(n-1) in p n)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(*Correction v2*)
|
||||||
|
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)
|
||||||
|
;;
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user