vault backup: 2023-10-20 15:39:01
This commit is contained in:
@ -282,20 +282,20 @@ Complexity : $O(\sum_{\forall{l\in{(el::ll)}}}^{}1+length(l))$
|
||||
## Exercise 6.1
|
||||
```Ocaml
|
||||
let rec decompose x =
|
||||
if x = 1 then
|
||||
return x
|
||||
else if x % 2 == 0 then
|
||||
let l = [] in
|
||||
if x = 1 then x::l
|
||||
else if x mod 2 == 0 then
|
||||
decompose(x/2)
|
||||
else if x%3 = 0 then
|
||||
else if x mod 3 = 0 then
|
||||
decompose(x/3)
|
||||
else if x%5 = 0 then
|
||||
else if x mod 5 = 0 then
|
||||
decompose(x/5)
|
||||
else if x%7 = 0 then
|
||||
else if x mod 7 = 0 then
|
||||
decompose(x/7)
|
||||
else if x%9 = 0 then
|
||||
else if x mod 9 = 0 then
|
||||
decompose(x/9)
|
||||
else if x%11 = 0 then
|
||||
else if x mod 11 = 0 then
|
||||
decompose(x/11)
|
||||
else if x%13 = 0 then
|
||||
else if x mod 13 = 0 then
|
||||
decompose(x/13)
|
||||
else return x
|
||||
else x::l
|
||||
|
Reference in New Issue
Block a user