Problème! Erreur de compilation Caml.
Bonjour, j'aurai besoin d'aide sur une fonction Caml que je fais dans le cadre d'un projet informatique.
J'ai une erreur de compilation et je n'arrive pas à déterminé d'où vient mon erreur.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
let miller_rabin n k =
if n < 2 then print_string "trop petit"
else if n != 2 && (n mod 2) = 0 then print_string "pair : non premier"
else
(
let s = n-1 in
while (s mod 2) = 0 do
s lsr 1
done;
for i = 0 to k do
let a = (Random.int (n-1))+1
and temp = s in
let mo = (puiss a temp) mod n in
while temp != (n-1) && mo != 1 && mo != (n-1) do
mo := (puiss mo 2) mod n;
temp := temp * 2;
done;
if mo != (n-1) && (temp mod 2) = 0 then print_string "pseudo";
done;
print_string "composé"
)
;; |
voici la réponse du compilateur :
Code:
1 2 3 4 5 6
|
File "D:/cours/M1/AC Algo et Complexite/Projet/arithmetique.ml", line 8, characters 1-8:
Warning 10: this expression should have type unit.
File "D:/cours/M1/AC Algo et Complexite/Projet/arithmetique.ml", line 15, characters 2-4:
Error: This expression has type int but an expression was expected of type
'a ref |
Voilà, toute proposition seras la bienvenue.