vault backup: 2023-10-25 16:43:46
This commit is contained in:
parent
a397067481
commit
9c5f0484ec
@ -1,8 +1,11 @@
|
|||||||
```Ocaml
|
```Ocaml
|
||||||
# let sum n =
|
# let sum n =
|
||||||
if n = 0 then
|
if n < 0 then
|
||||||
0
|
invalid_arg "n<0"
|
||||||
else if n < 0 then
|
|
||||||
failwith "input must be positive"
|
|
||||||
else
|
else
|
||||||
n + sum(n-1)
|
let rec sumrc n =
|
||||||
|
if n=0 then
|
||||||
|
0
|
||||||
|
else
|
||||||
|
n + sum(n-1)
|
||||||
|
in sumrc n;;
|
Loading…
x
Reference in New Issue
Block a user