Jump to content

Leonardo numbers: Difference between revisions

(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(→‎OCaml: add)
Line 1,527:
</pre>
 
=={{header|PerlOCaml}}==
<syntaxhighlight lang="ocaml">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]</syntaxhighlight>
{{out}}
<pre>
First 25 Leonardo numbers:
1 1 3 5 9 15 25 41 67 109 177 287 465 753 1219 1973 3193 5167 8361 13529 21891 35421 57313 92735 150049
First 25 Fibonacci numbers:
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368
</pre>
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">no warnings 'experimental::signatures';
use feature 'signatures';
559

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.