Anonymous recursion: Difference between revisions

m
→‎{{header|REXX}}: added whitespace, subroutine separater line, DO-end comment label. -- ~~~~
m (→‎{{header|Go}}: updated output)
m (→‎{{header|REXX}}: added whitespace, subroutine separater line, DO-end comment label. -- ~~~~)
Line 1,109:
to be OK with implementors, here is the REXX version:
<lang rexx>/*REXX program to show anonymous recursion (of a function/subroutine). */
 
numeric digits 1e6 /*in case the user goes kaa-razy.*/
 
do j=0 to word(arg(1) 12,1) /*use argument or the default: 12*/
say 'fibonacci('j") =" fib(j) /*show Fibonacci sequence: 0──>x */
end /*j*/
exit
/*-----------------------------------FIB subroutine---------------------*/
 
fib: procedure; if arg(1)>=0 then return .(arg(1))
say "***error!*** argument can't be negative."; exit
 
.:procedure; arg _; if _<2 then return _; return .(_-1)+.(_-2)</lang>
Output'''output''' when using the default input (<tt> 12 </tt>):
<pre style="height:15ex;overflow:scroll">
fibonacci(0) = 0
fibonacci(1) = 1