ruby fibs versions and tests for them

This commit is contained in:
Torsten Ruger
2015-11-20 19:12:58 +02:00
parent 9bcead4c1a
commit da4003c30a
2 changed files with 60 additions and 1 deletions

View File

@ -117,4 +117,32 @@ class Integer < Value
int mod4()
return self & 3
end
int fibr( )
if_plus( self - 2 )
int tmp
tmp = self - 1
int a = tmp.fibr( )
tmp = self - 2
int b = tmp.fibr( )
return a + b
else
return self
end
end
int fibw( )
int result = 1
int a = 0
int b = 1
int i = 2
while_plus( self - i )
result = a + b
a = b
b = result
i = i + 1
end
return result
end
end