text
stringlengths
0
601k
let rec fib_aux n a b = if n=1 then b else fib_aux (n-1) (b) (a+b) let fib_tl n = if n = 0 || n = 1 then 1 else fib_aux n 1 1;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> float(n) *. fact(n - 1);;
let binomial (n: int) (k: int) : float = if n < 0 || k < 0 then domain () else (if k > n then domain () else fact(n) /. (fact(k) *. fact(n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float(dx * dx) +. float(dy * dy)) ;;
let is_prime n = if n <= 1 then domain () else ( let rec is_prime_rec x n = if x*x <= n then ( is_prime_rec (x+1) n && n mod x!=0 ) else (true) in is_prime_rec 2 n );;
let rec fib_aux n a b = if n<=2 then a+b else( fib_aux (n-1) b (a+b)) let fib_tl n = if n < 0 then domain () else ( if n = 0 || n = 1 then 1 else( fib_aux n 1 1 ) );;
let rec fact (n: int): float = match n with | 0 -> 1. | n -> (fact (n - 1)) *. float_of_int(n);;
let binomial (n: int) (k: int) = if n < 0 then domain () else if (k<0) then domain() else ( (if (k = 0) then 1. else fact n /. (fact k *. fact (n - k))));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int((dx * dx) + (dy * dy))) ;;
let is_prime (n:int) : bool= if (n<=1) then domain () else let rec is_divisor (m:int) : bool = m*m > n || (n mod m != 0 && is_divisor (m+1)) in (n>=2) && is_divisor 2 ;;
let rec fib_aux n a b = if (n = 0) then a else if (n = 1) then b else fib_aux (n-1) b (a+b) let fib_tl (n:int):int = (fib_aux n 1 1);;
let rec fact (n: int): float = match n with | 0 -> 1. | n -> (fact (n - 1)) *. float_of_int(n);;
let binomial (n: int) (k: int) = if n < 0 then domain () else if (k<0) then domain() else ( (if (k = 0) then 1. else fact n /. (fact k *. fact (n - k))));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int((dx * dx) + (dy * dy))) ;;
let is_prime (n:int) : bool= if (n<=1) then domain () else let rec is_divisor (m:int) : bool = m*m > n || (n mod m != 0 && is_divisor (m+1)) in (n>=2) && is_divisor 2 ;;
let rec fib_aux n a b = if (n = 0) then a else if (n = 1) then b else fib_aux (n-1) b (a+b) let fib_tl (n:int):int = (fib_aux n 1 1);;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> float_of_int n *. fact(n - 1);;
let binomial (n: int) (k: int) = if n < 0 || k < 0 then domain () else (if k > n then domain () else fact n /. (fact k *. fact (n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = float_of_int (x2 - x1) in let dy = float_of_int (y2 - y1) in sqrt (dx *. dx +. dy *. dy) ;;
let is_prime n = if n <= 1 then domain() else let rec test (x: int) = if((x * x) > n) then true else let y = n mod x in match y with | 0 -> false | _ -> test (x+1) in test 2;;
let rec fib_aux n a b = match n with | 0 -> a | 1 -> b | _ -> fib_aux (n-1) b (a+b) let fib_tl n = fib_aux n 1 1;;
let fact (n: int): float = let x = float_of_int n in let rec fact_helper(y: float) (i: float): float = if (y < 0.) then domain() else match y with | 0. -> i | _ -> fact_helper (y -. 1.) (y *. i) in fact_helper x 1. ;; let binomialtest (n: int) (k: int): float = if n < 0 then domain () else if (n < k ) then domain () else ((fact n) /. (((fact k) *. (fact (n - k))))) ;;
let binomial (n: int) (k: int): float = if n < 0 then domain () else if (n < k ) then domain () else ((fact n) /. (((fact k) *. fact(n - k)))) ;;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int (dx * dx + dy * dy) ) ;;
let is_prime n = let rec notDivisible (m: int): bool = if (m * m > n) then true else (n mod m != 0 && notDivisible(m + 1)) in notDivisible 2 ;;
let rec fib_aux n a b = if n = 0 then a else fib_aux (n-1) b (a+b) ;; let fib_tl n = if n < 0 then domain () else fib_aux n 1 1 ;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> fact (n-1) *. float_of_int(n);;
let binomial (n: int) (k: int) = if n < 0 || k < 0 then domain () else if k = n then 1. else fact n /. (fact k *. fact (n - k));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int(dx * dx + dy * dy)) ;;
let is_prime n = let rec check_prime x y = match y with | 1 -> true | _ -> (x mod y != 0) && check_prime x (y-1) in check_prime n (n-1) ;;
let rec fib_aux n a b = if n=0 then a else if n=1 then b else fib_aux (n-1) (b) (a+b) let fib_tl n = fib_aux n 1 1;;
let rec fact (n: int): float = if n = 0 then 1. else (float_of_int n) *. fact(n - 1) ;;
let binomial (n: int) (k: int): float = if n < 0 || k < 0 then domain () else fact(n) /. (fact(k) *. fact(n-k));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = (float_of_int x1) -. (float_of_int x2) in let dy = (float_of_int y1) -. (float_of_int y2) in sqrt(dx *. dx +. dy *. dy) ;;
let is_prime (n: int): bool = if n <= 1 then domain() else let rec find_x (x: int) (n: int): bool= match (x, n) with |(1, _) -> true |(_,_) -> if x * x <= n && float_of_int(int_of_float( float n /. float x)) = float n /. float x then false else find_x (x-1) n in find_x n n ;;
let rec fib_aux n a b = if n = 0 then a else fib_aux (n - 1) b (a + b) ;; let fib_tl n = if n < 0 then domain() else fib_aux n 1 1 ;;
let rec fact (n: int): float = if n < 0 then domain () else match n with | 0 -> 1. | _ -> (float_of_int n) *. fact (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else if k = n then 1. else fact n /. (fact k *. fact(n-k)) ;;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt ( (float_of_int) (dx * dx + dy * dy)) ;; let rec helper (n:int) (x:int): bool = if x = n || x * x > n then true else if (n mod x) = 0 then false else helper n (x+1) ;;
let is_prime (n:int) : bool = if n <= 1 then domain() else helper n 2 ;;
let rec fib_aux n a b = if n = 0 then a else if n=1 then b else fib_aux (n-1) b (a+b) ;; let fib_tl n = if n < 0 then raise NotImplemented else fib_aux n 1 1;;
let rec fact (n: int): float = if n < 0 then domain () else match n with | 0 -> 1. | _ -> (float_of_int n) *. fact (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else if k = n then 1. else fact n /. (fact k *. fact(n-k)) ;;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt ( (float_of_int) (dx * dx + dy * dy)) ;; let rec helper (n:int) (x:int): bool = if x = n || x * x > n then true else if (n mod x) = 0 then false else helper n (x+1) ;;
let is_prime (n:int) : bool = if n <= 1 then domain() else helper n 2 ;;
let rec fib_aux n a b = if n = 0 then 1 else if n = 1 then b else fib_aux (n-1) b (a+b) ;; let fib_tl n = if n < 0 then raise NotImplemented else fib_aux n 1 1;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ when n < 0 -> domain() | _ -> (float_of_int (n)) *. (fact(n - 1));;
let binomial (n: int) (k: int) = if n < 0 || k < 0 then domain () else (if k > n then domain () else fact n /. (fact k *. fact (n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = if x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0 then domain () else let dx = (x1 - x2) in let dy = (y1 - y2) in sqrt (float_of_int (dx * dx + dy * dy)) ;;
let is_prime (n: int) : bool = if n <= 1 then domain () else let rec not_divisor (d: int): bool = d * d > n || (n mod d != 0 && not_divisor (d + 1)) in n > 1 && not_divisor 2;;
let rec fib_aux (n: int) (a: int) (b: int): int = if n == 0 then a else if n == 1 then b else fib_aux (n - 1) b (a + b) let fib_tl (n: int): int = if n < 0 then domain () else fib_aux n 1 1;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> float_of_int n *. fact (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else (if k > n or k < 0 then domain () else fact n /. (fact k *. fact (n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int (dx * dx + dy * dy)) ;;
let is_prime n : bool = let rec rec_helper x = if x * x > n then true else if n mod x = 0 then false else rec_helper (x + 1) in if n <= 1 then domain() else rec_helper 2;;
let rec fib_aux n a b = if n < 0 then b else fib_aux (n-1) (a+b) a let fib_tl n = if n < 0 then domain() else fib_aux (n + 1) 0 1;;
let fact (n: int) : float = let rec helper (n: int): float = match n with | 0 -> 1. | _ ->float_of_int (n) *. (helper (n - 1)) in helper n;;
let binomial (n: int) (k: int) = if n < 0 then domain () else (if n=0 || k=0 then 1. else if k = n then domain () else fact n /. (fact k *. fact (n - k))) ;;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int(dx * dx + dy * dy)) ;; distance (1,2) (4,6);;
let is_prime n = if n <= 1 then domain () else ( let rec check (n: int) (x: int) : bool = if x = 1 then true else ( if float_of_int(n/x) = float_of_int n /. float_of_int x then false else check (n) (x-1)) in let sqr = int_of_float(sqrt(float_of_int n)) in check n sqr ) ;; is_prime 341;; let pow (n:float) (k:float) : float = exp(k *. log(n));;
let rec fib_aux n a b = if (n = 0) then a else fib_aux (n-1) b (a+b) let fib_tl n = if n < 0 then domain() else fib_aux (n+1) 0 1 ;; fib_tl 0;;
let factorial (n: int) : float= if n < 0 then domain() else let rec helper n result : float= if n <= 1 then result else helper (n-1) (result *. (float_of_int n )) in helper n 1.0 ;; let fact (n: int): float = match n with | 0 -> 1. | _ -> (float_of_int n) *. factorial (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else (if k < 0 then domain () else (if k > n then domain () else (fact n /. (fact k *. fact (n - k))))) ;;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt ((float_of_int dx) ** 2. +. (float_of_int dy) ** 2.) ;;
let is_prime n = if n <= 1 then domain() else ( let rec helper_check input : bool = if (float_of_int input) ** 2. >= (float_of_int n) then true else( if (float_of_int (n / input)) = (float_of_int n) /. (float_of_int input) then false else helper_check (input + 1)) in helper_check 2);;
let rec fib_aux n a b = if n = 0 then a else fib_aux (n-1) b (a + b) ;; let fib_tl n = if n < 0 then domain() else fib_aux n 1 1 ;;
let rec fact (n: int) : float = match n with | 0 -> 1. | _ -> float_of_int n *. fact (n - 1);;
let binomial (n: int) (k: int) : float = if n < 0 then domain () else if k > n then domain () else fact n /. (fact k *. fact (n - k));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int(dx * dx + dy * dy));;
let is_prime (n: int) : bool = if n <= 1 then domain () else (let rec factor (x: int) : bool = if x * x <= n then if n mod x = 0 then false else factor (x + 1) else true in factor 2);;
let rec fib_aux (n: int) (a: int) (b: int) : int = if n <= 1 then b else fib_aux (n - 1) b (b + a) let fib_tl (n: int) : int = if n < 0 then domain () else fib_aux (n + 1) 0 1;;
let rec fact (n: int): float = if n<=1 then 1. else fact (n-1) *. float_of_int (n);;
let binomial (n: int) (k: int) = if n < 0 || k < 0 || k > n then domain () else ( fact n /. (fact k *. fact (n-k)) );;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int (dx * dx + dy * dy)) ;;
let is_prime n = if n<=1 then domain() else let rec not_div d= d*d>n || (n mod d != 0 && not_div (d+1)) in n!=1 && not_div 2;;
let rec fib_aux n a b = if n == 0 then a else if n == 1 then b else fib_aux (n-1) b (a+b);; let fib_tl n = if n<0 then domain() else fib_aux n 1 1;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> float_of_int(n) *. fact (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else (if k > n then domain () else fact n /. (fact k *. fact (n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int(dx * dx + dy * dy)) ;;
let is_prime (n:int):bool = let rec check_prime (n:int)(current:int) :bool= if current*current>n then true else if (n mod current)==0 then false else check_prime n (current+1) in check_prime n 2;;
let rec fib_aux n a b = if n = 0 then a else fib_aux (n-1) (a+b) a let fib_tl n = if n<0 then domain() else fib_aux n 1 0;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> float_of_int n *. fact (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else (if k > n then domain () else fact n /. (fact k *. fact (n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float_of_int(dx * dx+ dy * dy)) ;;
let is_prime n = if n<= 1 then domain () else let rec helper a b= if b= a then true else if (a mod b)= 0 then false else helper a (b+1) in helper n 2;;
let rec fib_aux n a b = if n<= 0 then b else (fib_aux (n-1) b (a+b));; let fib_tl n = fib_aux n 0 1;;
let rec fact (n: int): float = match n with | 0 -> 1. | _ -> (float) n *. fact (n - 1);;
let binomial (n: int) (k: int) = if n < 0 then domain () else (if k = n then 1. else fact n /. (fact k *. fact (n - k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in sqrt (float((dx * dx) + (dy * dy))) ;;
let is_prime n = if n <= 1 then domain() else let rec helper n x = if x * x<=n then if n mod x <> 0 then helper n (x+1) else false else true in helper n 2;;
let rec fib_aux n a b = match n with | 0 -> a | 1 -> b | _ -> fib_aux (n-1) b (a + b) let fib_tl n = fib_aux n 1 1;;
let rec fact (n: int): float = match n with | 0 | 1 -> 1. | n -> (float_of_int(n) *. (fact(n - 1)));;
let binomial (n: int) (k: int) = if n < 0 || k <0 then domain () else (if k > n then domain () else fact n /. (fact k *. fact (n-k)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x2 - x1 in let dy = y2 - y1 in sqrt (float_of_int(dx * dx + dy * dy)) ;;
let is_prime (n: int): bool = let rec prime (x: int) : bool = if n <=1 then domain () else if (x*x <= n) then if n mod x == 0 then false else prime (x+1) else true in prime 2;;
let rec fib_aux n a b = if n == 0 then a else if n == 1 then b else fib_aux (n-1) b (a+b) let fib_tl n = fib_aux n 1 1;;
let fact (n:int): float = let rec helper (n:float) (res:float) = if n = 0. then res else helper (n-.1.) (res *. n) in helper (float_of_int n) 1. ;;
let binomial (n: int) (k: int): float = if (n<0 || k<0 || n<k) then domain() else ( if k = n then 1. else let y = n - k in (fact n /. ( fact k *. fact y)));;
let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = x1 - x2 in let dy = y1 - y2 in (sqrt ( float_of_int (dx * dx + dy * dy))) ;;
let is_prime (n: int): bool = if n < 2 then domain() else let divider = 2 in let rec helper n divider = if (divider < n) then match n mod divider with 0 -> false | _ -> helper n (divider + 1) else true in helper n divider;;