Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Fibonacci-sequence/PIR/fibonacci-sequence-1.pir
Normal file
30
Task/Fibonacci-sequence/PIR/fibonacci-sequence-1.pir
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
.sub fib
|
||||
.param int n
|
||||
.local int nt
|
||||
.local int ft
|
||||
if n < 2 goto RETURNN
|
||||
nt = n - 1
|
||||
ft = fib( nt )
|
||||
dec nt
|
||||
nt = fib(nt)
|
||||
ft = ft + nt
|
||||
.return( ft )
|
||||
RETURNN:
|
||||
.return( n )
|
||||
end
|
||||
.end
|
||||
|
||||
.sub main :main
|
||||
.local int counter
|
||||
.local int f
|
||||
counter=0
|
||||
LOOP:
|
||||
if counter > 20 goto DONE
|
||||
f = fib(counter)
|
||||
print f
|
||||
print "\n"
|
||||
inc counter
|
||||
goto LOOP
|
||||
DONE:
|
||||
end
|
||||
.end
|
||||
50
Task/Fibonacci-sequence/PIR/fibonacci-sequence-2.pir
Normal file
50
Task/Fibonacci-sequence/PIR/fibonacci-sequence-2.pir
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
.sub fib
|
||||
.param int n
|
||||
.local int counter
|
||||
.local int f
|
||||
.local pmc fibs
|
||||
.local int nmo
|
||||
.local int nmt
|
||||
|
||||
fibs = new 'ResizableIntegerArray'
|
||||
if n == 0 goto RETURN0
|
||||
if n == 1 goto RETURN1
|
||||
push fibs, 0
|
||||
push fibs, 1
|
||||
counter = 2
|
||||
FIBLOOP:
|
||||
if counter > n goto DONE
|
||||
nmo = pop fibs
|
||||
nmt = pop fibs
|
||||
f = nmo + nmt
|
||||
push fibs, nmt
|
||||
push fibs, nmo
|
||||
push fibs, f
|
||||
inc counter
|
||||
goto FIBLOOP
|
||||
RETURN0:
|
||||
.return( 0 )
|
||||
end
|
||||
RETURN1:
|
||||
.return( 1 )
|
||||
end
|
||||
DONE:
|
||||
f = pop fibs
|
||||
.return( f )
|
||||
end
|
||||
.end
|
||||
|
||||
.sub main :main
|
||||
.local int counter
|
||||
.local int f
|
||||
counter=0
|
||||
LOOP:
|
||||
if counter > 20 goto DONE
|
||||
f = fib(counter)
|
||||
print f
|
||||
print "\n"
|
||||
inc counter
|
||||
goto LOOP
|
||||
DONE:
|
||||
end
|
||||
.end
|
||||
Loading…
Add table
Add a link
Reference in a new issue