vault backup: 2023-09-25 15:02:04

This commit is contained in:
Louis Gallet 2023-09-25 15:02:04 +02:00
parent be9639c188
commit f1a9359db3
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY

View File

@ -446,14 +446,21 @@ $$
$$
## Exercise 4.12 - Prime number
```OCaml
(* V1 *)
let prime n =
if n < 1 then
invalid_args "n should not be inferior to zero"
else if x = 2 then true
else
let rec pr n k =
if n mod k = 0 then
if n = k then
true
else if n mod k = 0 then
false
else
check n (k + 1)
in pr n 2;;
(* V2 *)
```