Fibonacci sequence: Difference between revisions

imported>Md1frejo
imported>Md1frejo
Line 4,295:
}</syntaxhighlight>
 
== {{header|ChapelChez Scheme}} ==
<syntaxhighlight lang="chapel">iter fib() {
var a = 0, b = 1;
 
while true {
yield a;
(a, b) = (b, b + a);
}
}</syntaxhighlight>
 
=={{header|Chef}}==
<syntaxhighlight lang="chef">Stir-Fried Fibonacci Sequence.
 
An unobfuscated iterative implementation.
It prints the first N + 1 Fibonacci numbers,
where N is taken from standard input.
 
Ingredients.
0 g last
1 g this
0 g new
0 g input
 
Method.
Take input from refrigerator.
Put this into 4th mixing bowl.
Loop the input.
Clean the 3rd mixing bowl.
Put last into 3rd mixing bowl.
Add this into 3rd mixing bowl.
Fold new into 3rd mixing bowl.
Clean the 1st mixing bowl.
Put this into 1st mixing bowl.
Fold last into 1st mixing bowl.
Clean the 2nd mixing bowl.
Put new into 2nd mixing bowl.
Fold this into 2nd mixing bowl.
Put new into 4th mixing bowl.
Endloop input until looped.
Pour contents of the 4th mixing bowl into baking dish.
 
Serves 1.</syntaxhighlight>
 
== Chez Scheme ==
<syntaxhighlight lang="scheme">
(define fib (lambda (n) (cond ((> n 1) (+ (fib (- n 1)) (fib (- n 2))))
Anonymous user