Jump to content

Y combinator: Difference between revisions

Added uBasic/4tH version
mNo edit summary
imported>Thebeez
(Added uBasic/4tH version)
Line 921:
1 1 2 3 5 8 13 21 34 55 </pre>
 
==={{header|uBasic/4tH}}===
{{Trans|Yabasic}}
<syntaxhighlight lang="basic">Proc _Test("fac")
Proc _Test("fib")
End
 
_fac
Param (2)
If b@ > 1 Then Return (b@ * FUNC (a@ (a@, b@-1)))
Return (1)
 
_fib
Param (2)
If b@ > 1 Then Return (FUNC (a@ (a@, b@-1)) + FUNC (a@ (a@, b@-2)))
Return (b@)
_Test
Param (1)
Local (1)
Print Show (a@), ": "; : a@ = Name (a@)
For b@ = 1 to 10 : Print FUNC (a@ (a@, b@)), : Next : Print
Return</syntaxhighlight>
{{Out}}
<pre>fac : 1 2 6 24 120 720 5040 40320 362880 3628800
fib : 1 1 2 3 5 8 13 21 34 55
 
0 OK, 0:39 </pre>
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">sub fac(self$, n)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.