(* Programmed by Jedidiah Barber *) (* Licensed under the Sunset License v1.0 *) let fibonacci ~len = let rec fib a b r = if List.length (r) > len - 1 then r else fib b Z.(a + b) (a :: r) in Array.of_list (List.rev (fib Z.zero Z.one [])) let pagoda ~len = let open Z in let rec b n = if n = zero then zero else (uneven n) / ~$2 mod ~$2 and a n = if ~$n = zero then minus_one else b (~$n + one) - b (~$n - one) and uneven n = if is_even n then uneven (n / ~$2) else n in Array.init len a let random ~len = Random.self_init (); let f n = Z.of_int ((Random.int 1000000000) - 500000000) in Array.init len f