Jump to content

Anonymous recursion: Difference between revisions

Added 11l
(Added 11l)
Line 19:
If possible, demonstrate this by writing the recursive version of the fibonacci function   (see [[Fibonacci sequence]])   which checks for a negative argument before doing the actual recursion.
<br><br>
 
=={{header|11l}}==
{{trans|C++}}
<lang 11l>F fib(n)
F f(Int n) -> Int
I n < 2
R n
R @f(n - 1) + @f(n - 2)
R f(n)
 
L(i) 0..20
print(fib(i), end' ‘ ’)</lang>
{{out}}
<pre>
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
</pre>
 
=={{header|Ada}}==
1,481

edits

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