RosettaCodeData/Task/Leonardo-numbers/OCaml/leonardo-numbers.ocaml
2023-07-01 13:44:08 -04:00

11 lines
339 B
Text

let seq_leonardo i =
let rec next b a () = Seq.Cons (a, next (a + b + i) b) in
next
let () =
let show (s, a, b, i) =
seq_leonardo i b a |> Seq.take 25
|> Seq.fold_left (Printf.sprintf "%s %u") (Printf.sprintf "First 25 %s numbers:\n" s)
|> print_endline
in
List.iter show ["Leonardo", 1, 1, 1; "Fibonacci", 0, 1, 0]