Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Anonymous-recursion/Ring/anonymous-recursion.ring
Normal file
37
Task/Anonymous-recursion/Ring/anonymous-recursion.ring
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Project : Anonymous recursion
|
||||
|
||||
t=0
|
||||
for x = -2 to 12
|
||||
n = x
|
||||
recursion()
|
||||
if x > -1
|
||||
see t + nl
|
||||
ok
|
||||
next
|
||||
|
||||
func recursion()
|
||||
nold1=1
|
||||
nold2=0
|
||||
if n < 0
|
||||
see "positive argument required!" + nl
|
||||
return
|
||||
ok
|
||||
if n=0
|
||||
t=nold2
|
||||
return t
|
||||
ok
|
||||
if n=1
|
||||
t=nold1
|
||||
return t
|
||||
ok
|
||||
while n
|
||||
t=nold2+nold1
|
||||
if n>2
|
||||
n=n-1
|
||||
nold2=nold1
|
||||
nold1=t
|
||||
loop
|
||||
ok
|
||||
return t
|
||||
end
|
||||
return t
|
||||
Loading…
Add table
Add a link
Reference in a new issue