vault backup: 2023-09-15 14:51:50

This commit is contained in:
2023-09-15 14:51:50 +02:00
parent b5ec7a1ce4
commit c297a59106
3 changed files with 18 additions and 5 deletions

View File

@ -102,3 +102,6 @@ An accumulator is a thing that try to get our result. In CAML we trying to not u
| n -> rev (inv*10 + n mod 10)(n/10)
in rev 0 n;;
```
## 4.3. Complexity
Exemple with egypt (4.10) vs multiply (4.6)

View File

@ -355,4 +355,14 @@ let rec multiply x y =
multiply (x / 2) (y * 2)
else
y + multiply (x / 2) (y * 2)
(*correction*)
# let egypt a b =
let (a, b) = if a > b then (a,b) else (b,a) in
let rec eg = function
| 0 -> 0
| b -> 2*eg(b/2) + (if b mod 2 = 0 then 0 else a)
in
eg b;;
```