>>38,39
It's always let x = 3 in. Not let x = 3;
let divide x y = x / y, x mod y ;;
let rec extended_gcd a b =
if a > b then extended_gcd b a
else
if b = 0 then (1, 0)
else
let qr = divide a b in
let st = extended_gcd b (snd qr) in
(snd st, (fun s q t -> s - q * t) (fst st) (fst qr) (snd st))
;;
Also, this took me a while to figure out: If you are going to put multiple statements in an if block then you have to start with begin ... end. Ex:
let rec extended_gcd a b =
if a > b then extended_gcd b a
else
if b = 0 then (1, 0)
else begin
Printf.printf "a: %d b: %d" a b ;
let qr = divide a b in
let st = extended_gcd b (snd qr) in
(snd st, (fun s q t -> s - q * t) (fst st) (fst qr) (snd st))
end
;;