Anonymous recursion: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
|||
Line 19: | 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. |
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> |
<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}}== |
=={{header|Ada}}== |